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 is known as implicit casting. The same occurs if you assign an int value to a double. Quick example
double d = 1;
1 is an int but it is implicitly cast to double (1.0).
int
double