Can someone please explain to me the difference between the Comparator interface and the Comparable interface. When would I need to override each? [ February 21, 2002: Message edited by: Rajinder Yadav ]
<a href="http://www.rajindery.com" target="_blank" rel="nofollow">Rajinder Yadav</a><p>Each problem that I solved became a rule which served afterwards to solve other problems. --Rene Descartes
Erik thanks for the tip! I looked them up in the API and also looked up Collections.sort() under java.utils which helped clear it up for me. [ February 21, 2002: Message edited by: Rajinder Yadav ]
<a href="http://www.rajindery.com" target="_blank" rel="nofollow">Rajinder Yadav</a><p>Each problem that I solved became a rule which served afterwards to solve other problems. --Rene Descartes
Collections.sort() takes a List as argument so that all classes implementing it (AbstractList, ArrayList, LinkedList, Vector) can be given as argument, and thus, sorted. [ February 21, 2002: Message edited by: Valentin Crettaz ]
Jenny, along with what Roy said, for Maps there are two methods values() and keySet() Map.values() returns a Collection containing all the values, which could be sorted using Collections.sort() Likewise Map.keySet() return a set of all possible keys and again you could sort them using Collections.sort() So if you had some special sorting need this is one way it could be handled with a Map interface. [ February 22, 2002: Message edited by: Rajinder Yadav ]
<a href="http://www.rajindery.com" target="_blank" rel="nofollow">Rajinder Yadav</a><p>Each problem that I solved became a rule which served afterwards to solve other problems. --Rene Descartes
You don't like waffles? Well, do you like this tiny ad?
a bit of art, as a gift, the permaculture playing cards