// common string methods // see http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html // Savitch: pp 82-84 public class string_methods { public static void main(String[] args) { String S1 = "hello"; char[] c1 = {'h','e','l','l','o'}; // Find index of character in String: System.out.println("1: "+ S1.indexOf('h') ); System.out.println("2: "+ S1.indexOf('x') ); System.out.println("3: "+ S1.indexOf('l') ); if (S1.indexOf('l') == 2) System.out.println("4: great (2) !"); if (S1.indexOf('l') == 3) System.out.println("4: great (3) !"); // Length of String: System.out.println("5: "+ S1.length() ); // Convert String into character array: char[] tmp = S1.toCharArray(); System.out.print("6: "); for(int i=0;i