In Java, whether a Collection support add depends on the concrete class.
Say I have code like:
List<String> otherNames = getOthers();
names.add(myName);
The second line will raise UnsupportedOperationException if the underlying List don't support this, one common example is Collections.emptyList().
Of course, we can create a new list to hold the content, but I wonder is there is way to test the list?