Help creating a hash from a hash map

I managed to read a four-column text file into a hash file and make it write to the output file. However, I need to get the second column (different values) in the hashset and write to the output file. I was able to create a hashset, but it captures everything and does not sort it. By the way, I'm a newbie, so please bear in mind when you answer. Thanks

+3
source share
2 answers

Neither HashSetare HashMapintended for sorting. These are fundamentally unsorted data structures. You should use an implementation SortedSet, for example TreeSet.

+4
source

Some of the speculations associated with Mr Skeets are also responsible for the apparent confusion ...

, TreeSet? , () ( ) - .

, , , TreeMap 2: nd , . , .

: - , .

Set. - , String. add , iterating . add(), for loop iterator().

"" "" ; add - - a String - , String[]

(-, TreeSet ( ), String. , , .)

String key = splittedLine[1]; // 2:nd element

" " . . ( ...: -)

+1

Source: https://habr.com/ru/post/1763820/


All Articles