| Return | Method | Summary |
|---|---|---|
| int | compareTo(Short anotherShort) | Compares two Short objects numerically. |
| boolean | equals(Object obj) | Compares this object to the specified object. |
compareTo(Short anotherShort) compares two Short objects numerically. It returns
| Value Returned | Meaning |
|---|---|
| 0 | if this Short is equal to the argument Short; |
| < 0 | if this Short is numerically less than the argument Short; and |
| > 0 | if this Short is numerically greater than the argument Short. |
public class Main {
public static void main(String[] args) {
Short shortValue1 = new Short("10");
Short shortValue2 = new Short("11");
System.out.println(shortValue1.compareTo(shortValue2));
}
}
The output:
-1
public class Main {
public static void main(String[] args) {
Short shortValue1 = new Short("10");
Short shortValue2 = new Short("11");
System.out.println(shortValue1.equals(shortValue2));
}
}
The output:
false
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. |