posted 20 years ago
Let's say I have a Number array filled with different kinds of Numbers
Number[] numArray = {new Integer(6), new Long(10), new Float(5.9), new Double(10.1)};
How would I go about sorting through such a list WITHOUT knowing what datatype the number actually is? The Number class doesn't support the compareTo() method.
In other words:
The line in question is the "***".
Is there an easy way to compare Number objects that are of different subclasses? Perhaps there isn't or it's simply escaping me-- it's been a long day. Remember, I don't want to assume that the first Number is an Integer, the next one is a Long, etc. The order and types of Numbers in numArray can't be assumed.