Return | Method | Summary |
---|---|---|
int | compareTo(Integer anotherInteger) | Compares two Integer objects numerically. |
boolean | equals(Object obj) | Compares this object to the specified object. |
Returns from compareTo(Integer anotherInteger)
Returns | Meaning |
---|---|
0 | if this Integer is equal to the argument Integer; |
less than 0 | if this Integer is less than the argument Integer; |
greater than 0 | if this Integer is greater than the argument Integer. |
public class Main {
public static void main(String[] args) {
Integer integer1 = new Integer("1");
Integer integer2 = new Integer("2");
System.out.println(integer1.compareTo(integer2));
}
}
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. |