This is more a curiosity question than anything. Say I supply a LinkedHashMap with access ordering set to true to Collections.unmodifiableMap(). Since reads are actually modifying the map. Does it mean there are cases where the view returned by unmodifiableMap() is actually modifiable?
public class MyApp { /** * @param args */ public static void main(String[] args) { Map<String, String> m = new LinkedHashMap<String, String>(16,.75f,true); Collections.unmodifiableMap(m); }
}
The Map is modifying itself. Collections.unmodifiableMap()
only provides a decorator for the Map which disallows modifications, it does not make the Map itself unmodifiable.