Answer by VGR for Deciding to use Comparable or Comparator
If your order was based only on numbers, Comparable would be fine.However, since your order (sometimes) involves lexical order of text,a Comparator class is better, since use of Comparable would mean...
View ArticleAnswer by onon15 for Deciding to use Comparable or Comparator
If there is a "natural" ordering, use Comparable. Rule of thumb for figuring out if the ordering is "natural" is, whether the order of the objects will always be that.Having said that, the decision...
View ArticleAnswer by Denys Séguret for Deciding to use Comparable or Comparator
The order you define here on your Product is very specific and will probably change in future versions of your programmight be enriched with contextual parameterizationwon't cover new featuresSo it can...
View ArticleDeciding to use Comparable or Comparator
My program implements a Product class whose objects contain the following instance variables: name, priority, price, and amount.I have a LinkedList of Product objects that I need to sort before doing...
View Article
More Pages to Explore .....