I've got a class, "Accumulator", that implements the Comparable compareTo method, and I'm trying to put these objects into a HashSet.
When I add() to the HashSet, I don't see any activity ...
need an example on how to use a comparable class on a hashset to get an ascending order?
Let say we have a hashset like:
HashSet hs=new HashSet();
How can i get the hs ...
I'm making a TreeSet of Point2D.Float type, creating it with a custom Comparable class that implements compare() of Point2D type. However, on calling "contains" on the TreeSet, I get a classcast ...
Option 1: Make a list which implements Comparable and sort it using collections.sort(List l) every time you add a value.
Option 2: Make a TreeSet (which keeps itself sorted all the time).
Which ...
Say I have a class called Player which implements Comparable. And I want to put the Player object into a TreeSet. Inside the Player class I have a compareTo method. Will then the TreeSet be automatically use the compareTo method inside the Player class to put the Player elements inside the TreeSet??