This must be a fairly common occurrence where I have a map and wish to thread-safely expose its key set:
public MyClass { Map<String,String> map = // ... public final ...
It is a old code and am debugging it. I have a Map (myMap) with size 2 (for sure). Keys are null and 1.
Map
null
1
SortedSet mySet = new TreeSet(); mySet.addAll(myMap.keySet()); Iterator mySetIterator = mySet.iterator(); while ...