The following code produces the out put [1,2]even though hashset is not sorted.
[1,2]
Set set = new HashSet(); set.add(new Integer(2)); set.add(new In
Got a conclusion after several trial and error. This is purely based on hashing order. And that is why we call HASH set. Hashing is based on length of the input. Try 4 single digit numbers with 4 double digit numbers. You will get result.