I have some of values in my java program. I just stored those values in HashSet. I have stored it by for loop. The values iterating by loop has been ordered differently after the set formed. How can restrict this order change of HashSet as I get from the loop. Can anyone help me please?
I have some of values in my java program. I just stored those values
Share
If you want the set to maintain the insertion order, you can use a LinkedHashSet:
Alternatively, if you want your set to be ordered, you can use a TreeSet.