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 Long extends Number {
public final class Long extends Number implements Comparable<Long> {
public static final Class TYPE = Class.forCanonicalName("J");
public static final Long MAX_VALUE = 9223372036854775807l;
@ -22,6 +22,10 @@ public final class Long extends Number {
return new Long(value);
}
public int compareTo(Long o) {
return value > o.value ? 1 : (value < o.value ? -1 : 0);
}
public boolean equals(Object o) {
return o instanceof Long && ((Long) o).value == value;
}