I read that java.util.HashSet
doesn't sort. However when I execute this code
import java.util.*;
public class Example {
public static void main(String[] args) {
Set set = new HashSet();
set.add(newInteger(5));
set.add(new Integer(2));
set.add(new Integer(1));
System.out.println(set);
}
}
the output is
[1, 2, 5]
Why are the values sorted?