On a recent question I came accross the use of the Number
abstract class.
Now since Java 8 is here, there are default methods, so Number
could be an interface and written as:
public interface Number {
public int intValue();
public long longValue();
public float floatValue();
public double doubleValue();
default public byte byteValue() {
return (byte)intValue();
}
default public short shortValue() {
return (short)intValue();
}
}
Would old code using the Number
abstract class still compile if this were the case? Are there any actual benefits in making Number
an interface rather than an abstract class?