The output from the following code is 123 because substring takes from beginIndex to EndIndex - 1. However, I am surprised how char
123
substring
char
This goes all the way back to C, where char is in essence a narrow integer type and gets implicitly converted to int whenever necessary.
int
In Java, this is technically known as a "widening primitive conversion", and is covered in section 5.1.2 of the JLS.