1 class Find {
2
3 public static void main(String[] args) {
4 final String s = "Madam, I'm Adam";
5
6 System.out.println (s.indexOf('\'')); // 8
7 System.out.println (s.indexOf('\'', 8)); // 8
8 System.out.println (s.indexOf('\'', 9)); // -1
9 System.out.println (s.indexOf('a', 100)); // -1
10 System.out.println (s.indexOf('X')); // -1
11
12 // Retrieve the first word.
13 System.out.println (s.substring(0, s.indexOf(' '))); // Madam,
14 }
15 }
16