// Helene Martin, Garfield HS
// Demonstrates use of String methods.
public class StringExamples {
	public static void main(String[] args) {
		//     index 0123456789012
		String s1 = "Marla Singer";				
		String s2 = "Helene Martin";
		System.out.println(s1.length());         // 12
		System.out.println(s1.indexOf("e"));     // 10
		System.out.println(s1.substring(6, 10));  // "Sing"
	
		String s3 = s2.substring(7, 13);
		System.out.println(s3.toLowerCase());    // "martin"
		
		//       index 012345678901234567890123456789
		String book = "Fear and Loathing in Las Vegas";
		
		// extract "Loathing"
		String loath = book.substring(9, 17);
		System.out.println(loath);
		
		// in general, how do you extract the first word?  Write a method.
		// use the index of the first space
		System.out.println(getFirstWord(book));
	}
	
	public static String getFirstWord(String word) {
		return word.substring(0, word.indexOf(" "));
	}
}
