Click here to Skip to main content
15,885,944 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I'm trying to use addAll() method for inserting elements in the ArrayList..

But getting error...
Java
List elements=new ArrayList();
Collections.addAll(elements, "aaa", "Android",123,"java");

But it suggesting use Collection istead of List...
Java
Collection elements=new ArrayList();

what is the reason..???why we its not allowed to use List interface..
Posted
Updated 18-Oct-12 19:38pm
v2

Collection is the mother of all Lists - that's why a Collection can be a ArrayList.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900