art applecart
The method
public String substring(int beginIndex )
creates a new string. The original string is not changed. There are two tricky rules:
beginIndex
is exactly equal to the length of the original string, a substring is created, but it
contains no characters (it is an empty string)beginIndex
is greater than the length of the original string,
or a negative value, an
IndexOutOfBoundsException
is thrown (and for now, your program crashes).What string is formed by the following expressions? (click on the button when you have decided)