+ 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?

19th Nov 2018, 10:22 AM
Serhiy Matsenko
Serhiy Matsenko - avatar
2 ответов
+ 3
Hashset is an unordered collection. Use an arraylist instead?
19th Nov 2018, 11:38 PM
Steven Trippier
Steven Trippier - avatar
+ 2
Then make your Sportsman class implement the comparable interface. Override the compareto method. https://www.javatpoint.com/Comparable-interface-in-collection-framework
19th Nov 2018, 11:40 PM
Steven Trippier
Steven Trippier - avatar