The line3 which is <Collection>containsAll(<Collection> is checking whether the given object has all the elements in another collection. If all the elements were present it is going to return true and if not it is going to return false. If you don't pass Collection in any of the comparison then you would get an compilation error.
I always find the best way to answer this sort of question is to look at the javadoc.
If you look at the Collection interface, the containsAll method has signature:
therefore you can check against any type of collection that contains Objects. It could (but doesn't) limit the collection to the E type parameter. It also says that the ClassCastException is optional so therefore dependent upon the implementation.
Incidentally, the containsAll method in ArrayList is inherited from the AbstractCollection so you may want to look there for more info.
One way you could think about the implementation is like so (you will be able to find the actual source somewhere):
[ July 25, 2008: Message edited by: Paul Beckett ]
Joined: Jun 29, 2007
Hi Paul Read the api for containsAll() method,so you are saying list of elements in one collection can be compared with list of elements of another collection with/without using generics.
What is the exact use of wildcard capture? Please reply as i am prpearing for scjp!!!