Compare two characters

ReturnMethodSummary
intcompareTo(Character anotherCharacter)Compares two Character objects numerically.
booleanequals(Object obj)Compares this object against the specified object.

public class Main {
  public static void main(String[] argv) {
    Character character1 = new Character('a');
    Character character2 = new Character('b');
    System.out.println(character1.compareTo(character2));
  }
}

The output:


-1
java2s.com  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.