// Helene Martin, CSE 142 // Demonstrates usage of String methods public class StringDemo { public static void main(String[] args) { String name = "Barack Obama"; System.out.println(name.length()); int rIndex = name.indexOf("r"); System.out.println(rIndex); int space = name.indexOf(" "); String fname = name.substring(0, space); System.out.println(fname); // case changing methods also return so // we need to save their results back into // the original string fname = fname.toUpperCase(); // similar to x = x + 1 System.out.println(fname); } }