Character: compareTo(Character anotherCharacter) : Character « java.lang « Java by API






Character: compareTo(Character anotherCharacter)

  
public class Main {
  public static void main(String args[]) {
    Character a = new Character('a');
    Character a2 = new Character('a');
    Character b = new Character('b');

    int difference = a.compareTo(b);

    if (difference == 0) {
      System.out.println("a is equal to b.");
    } else if (difference < 0) {
      System.out.println("a is less than b.");
    } else if (difference > 0) {
      System.out.println("a is greater than b.");
    }

    System.out.println("a is " + ((a.equals(a2)) ? "equal" : "not equal")
        + " to a2.");

    System.out.println("The character " + a.toString() + " is "
        + (Character.isUpperCase(a.charValue()) ? "upper" : "lower") + "case.");
  }
}

   
    
  








Related examples in the same category

1.Character.COMBINING_SPACING_MARK
2.Character.MATH_SYMBOL
3.Character.NON_SPACING_MARK
4.Character.TITLECASE_LETTER
5.new Character(char charValue)
6.Character: charValue()
7.Character: digit(char ch, int radix)
8.Character: equals(Object obj)
9.Character: forDigit(int digit, int radix)
10.Character: isDigit(char charValue)
11.Character.isISOControl(char ch)
12.Character.isIdentifierIgnorable(char ch)
13.Character.isJavaIdentifierPart(char ch)
14.Character.isJavaIdentifierStart(char ch)
15.Character: isLetter(char charValue)
16.Character: isLetterOrDigit(char charValue)
17.Character: isLowerCase(char charValue)
18.Character.isUnicodeIdentifierPart(char ch)
19.Character.isUnicodeIdentifierStart(char ch)
20.Character: isUpperCase(char charValue)
21.Character.isWhitespace(char ch)
22.Character: toString()
23.Character.UnicodeBlock.of(char c)