Only one value is legitimate: 0 .
substring()substring( int from, int to ) |
Create a new object that contains the characters of the method's string
from index from to index to-1. |
Throws an IndexOutOfBoundsException if from is negative
or if from is larger than to. |
There is a second version of substring().
Remember those tricky rules about the second version of the method:
from is negative, an
IndexOutOfBoundsException
is thrown.from is larger than to, an
IndexOutOfBoundsException
is thrown.to is larger than the length, an
IndexOutOfBoundsException
is thrown.from equals to, and both are within range,
then an empty string is returned.These rules make sense. If something can't be done, Java throws an exception.
What do the following statements create?