When is the unmodifiablemap (really) necessary?

Collections.unmodifiableMap guarantees that the map will not be modified. It’s mostly useful if you want to return a read-only view of an internal map from a method call, e.g: class A { private Map importantData; public Map getImportantData() { return Collections.unmodifiableMap(importantData); } } This gives you a fast method that does not risk the client … Read more

Collections.unmodifiableList and defensive copy

Yes, you understood it correctly. The idea is that the object returned by umodifiableCollection can’t directly be changed, but could change through other means (effectively by changing the internal collection directly). As long as something has access to the internal list, the “unmodifiable” collection could be changed. That’s why you usually construct a unmodifiable collection … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)