addAll is defined by the Collection interface, so it is supported by any concrete Class that implements this interface.
Joined: Jan 30, 2000
Well, to be fair, the Collection interface lists the method as optional. It can throw an UnsupportedOperationException in some cases. So in truth, there is no general answer to Imran's last question; it depends on the specific Collection implementation that we are talking about. Most collections implement this method, but a few, like the implementations returned by Collections.unmodifiableXXX() and Arrays.asList(), do not. The idea of optional methods in an interface is a bit odd, and in Java I think it's unique to the collections framework. Generally an interface promises that a method will be available in an implementing class. But with an optional method, the promise is that the method will be present in the class, but it may throw an exception. So the method is available, except that it really isn't.