Lecture 23
15
Substrings
•String s = “hello, world”;
•s.startsWith(“hello”) returns true
•s.substring(3,8) returns “lo, w”                // from index 3 to index 8-1 •s.substring(7) returns “world”                 // index 7-end
•s.indexOf(“world”) returns 7
•s.indexOf(“hello”) returns 0
•s.indexOf(“foo”)   returns -1