Short question;
I've read the Javadocs for Comparable and Comparator and I don't understand the differences. Comparable throws a NullPointerException and Comparable is implemented by many more classes, so its methods are more readily available, are they the only differences?
The second part of my question is Why doesn't Number implement Comparable but something like BigDecimal does? It would appear that only AtomicInteger and AtomicLong do not implement Comparable from the Number class. Is this why? Why aren't 'Atomic' classes Comparable?
Long Question;
I ask this because I am attempting to take a JIVariant from J-Interop convert it to a Object (has a possibility to be a Boolean, String or Number) for easy displaying and performing a switch on the return, in the event that its a Number I wish to use relational operators to determine how it compares to each individual operators.
My testing has shown that non-primitives cannot be compared, unless you are using Comparable's compareTo().
I am tempted to convert the number to something less generic to give me the functionality I require but I am concerned about overflow and memory usage. I was thinking of going BigDecimal but i know Floats have floating point precision problems. How would the more experienced StackOverflow members handle this problem?