Thursday, 5 September 2013

How is this hashset producing output in a sorted manner?

How is this hashset producing output in a sorted manner?

The following code produces the out put [1,2]even though hashset is not
sorted.
Set set = new HashSet();
set.add(new Integer(2));
set.add(new Integer(1));
System.out.println(set);
Why is that?

No comments:

Post a Comment