+ 1
How to sort my HashSet?
class Sportsman { private int SportsmanNumber; private String SecondName; private String ClubName; private int FinishTime; } HashSet<Sportsman> set = new HashSet<Sportsman>(); How to sort by finish time?
2 Antworten
+ 3
Hashset is an unordered collection. Use an arraylist instead?
+ 2
Then make your Sportsman class implement the comparable interface.
Override the compareto method.
https://www.javatpoint.com/Comparable-interface-in-collection-framework