Java Reference
In-Depth Information
// Since all Java indexes start with 0, index 12 is actually the
// 13th position.
// This method returns a char data type, which is converted
// into a String by the println() method.
System.out.println ("charAt(12) = " +
englishCaps.charAt(12));
...
indexOf(M) = 12
charAt(12) = M
// Get the substring at position 12 through 17.
System.out.println ("substring(12, 17) = " +
englishCaps.substring (12, 17));
...
substring(12, 17) = MNOPQ
// Make a new String with the lowercase representation of this
// String.
String englishLower = englishCaps.toLowerCase ();
System.out.println ("englishLower = " +
englishLower);
...
englishLower = abcdefghijklmnopqrstuvwxyz
// Compare the two English Strings using two different String
// methods.
System.out.println ("compareTo = " +
englishCaps.compareTo (englishLower));
System.out.println ("equalsIgnoreCase = " +
englishCaps.equalsIgnoreCase (englishLower));
...
compareTo = -32
equalsIgnoreCase = true
// Create a duplicate of englishCaps.
// Compare it to englishCaps using two String comparison
// methods.
String temp = englishCaps;
System.out.println ("compareTo = " +
englishCaps.compareTo (temp));
System.out.println ("equals = " +
englishCaps.equals (temp));
...
compareTo = 0
equals = true
// Compare the two String reference variables.
Search WWH ::




Custom Search