You have no reason to expect output [BLA, TEST]in JDK6 or JDK8, because Javadoc does not promise that the elements HashSetwill be printed in the insertion order (or any order). Different implementations allow the creation of a different order.
JDK, LinkedHashSet, :
Set<String> types = new LinkedHashSet<String>();
String result;
types.add("BLA");
types.add("TEST");
System.out.println (types);
[BLA, TEST]
.
, Javadoc, , , . , AbstractCollection toString() ( HashSet LinkedHashSet) , .
java.util.AbstractCollection.toString()
. , , ( "[]" ). "," ( ). , String.valueOf(Object).