public class StringTest { public static void main( String[] args ) { String s = "moose"; // The next line doesn't compile, because [] notation doesn't work with String. // s[0] = 'g'; // This also fails to compile, because String objects are unmodifiable // after they're initialized (and thus String has no setCharAt method). // s.setCharAt( 0, 'g' ); StringBuffer sb = new StringBuffer( "moose" ); // But StringBuffer gives you the ability to modify your string after initialization. sb.setCharAt( 0, 'g' ); System.out.println( sb ); } }