Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Predictability has nothing whatsoever to do with it. Comparable is a standard Java interface with perfectly clear semantics, implemented by all the Java wrapper types, and the sorting order of Comparable objects is both well-defined and predictable. In fact, both Comparators call the very same Integer.compareTo() method.Originally posted by AMIT ARADHYE:
Both the alternatives are workable and satisfies my requirement. But Barry's is more effective and gives predictable results than Peters. The reason behind this is ..
Barry is comparing two objects in 'Integer' form (which in my case is specific requirement) where as Peter is opting for 'Object' form.
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
"JavaRanch, where the deer and the Certified play" - David O'Meara
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
"I'm not back." - Bill Harding, Twister
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |