make Boolean, Byte, Short, etc. implement Comparable

This commit is contained in:
Joel Dice
2007-10-28 18:51:08 -06:00
parent 7f1837fecd
commit 09cedfd7cb
5 changed files with 25 additions and 5 deletions

View File

@ -1,6 +1,6 @@
package java.lang;
public final class Short extends Number {
public final class Short extends Number implements Comparable<Short> {
public static final Class TYPE = Class.forCanonicalName("S");
public static final short MAX_VALUE = 32767;
@ -14,6 +14,10 @@ public final class Short extends Number {
return new Short(value);
}
public int compareTo(Short o) {
return value - o.value;
}
public boolean equals(Object o) {
return o instanceof Short && ((Short) o).value == value;
}