K&B SCJP5 book 7.2 says:
HashSets and LinkedHashSets do not guarantee any ordering.
I doubt it (not mentioning the typo "s" following the class name).
Is LinkedHashSet supposed to be ordered?
I tried following code:
Set<
String> s = new LinkedHashSet();
s.add("a");
s.add("b");
s.add("c");
s.add("d");
for(String n: s){
System.err.print(n+" ");
}
It consistently gives me ordered output: a b c d
Actually the book is contradictory to itself on 7.1 says LinkedHashSet is ordered by insertion order.