String methods and indices
A String's characters are numbered from 0 to length() minus 1, so substring(a, b) takes the characters from a up to but not including b, and Strings are compared with equals and compareTo, never with ==.
From AP Computer Science A.