HashSet
don't maintain the order of insertion item
LinkedHashSet
maintain the order of insertion item
Example
Set<String> set = ...;// using new HashSet<>() OR new LinkedHashSet<>()
set.add("2");
set.add("1");
set.add("ab");
for(String value : set){
System.out.println(value);
}
HashSet
output
1
ab
2
LinkedHashSet
output
2
1
ab