// String comparison, case-sensitive and insensitive.
String apple = "apple";
String orange = "orange";

// case-sensitive compare for equality, faster than order comparison.
boolean same = apple.equals( orange );

// case-insensitive compare for equality, slower that case-sensitive comparison.
boolean same = apple.equalsIgnoreCase( orange );

// case-sensitive compare for order.
// +ve if apple>orange, 0 if apple==orange, -ve if apple<orange
int order = apple.compareTo( orange );

// case-insensitive compare for order.
// +ve if apple>orange, 0 if apple==orange, -ve if apple<orange
int order = apple.compareToIgnoreCase( orange );

// If you are going compare the same strings over and over,
// and you want to compare them in a case-insensitive way, it may pay
// to convert them to lower case, and use the faster case-sensive compare.
String lcApple = apple.toLowerCase();
String lcOrange = orange.toLowerCase();

// effectively a case-insensitive compare for equality,
boolean same = lcApple.equals( lcOrange );

// effectively a case-insensitive compare for order.
// +ve if apple>orange, 0 if apple==orange, -ve if apple<orange
int order = lcApple.compareTo( lcOrange );