Difference
Hi friends,
can any one say what is the different between 2 declaration ?
List<String> words =new ArrayList<String>();
and
ArrayList<String> words =new ArrayList<String>();
Thanks
Hi friends,
can any one say what is the different between 2 declaration ?
List<String> words =new ArrayList<String>();
and
ArrayList<String> words =new ArrayList<String>();
Thanks
> meaning with the first declaration, you won't be able
> to call the methods defined in arraylist without
> casting (except for overriden methods), i think
correct. Also meaning, your program doesn't care whether it's an ArrayList or LinkedList or any other list, which is very useful if you later have to change the implementation because a LinkedList is more appropriate than an ArrayList or whatever.
>List<String> words = new ArrayList<String>();
Here u can use all methods of List only....
>ArrayList<String> words = new ArrayList<String>();
Here u can enjoy methods of List as well as ArrayList....
I hopet his will be clear......
Thanks