Possible Duplicate:
Type List vs type ArrayList in Java
Hi I have been asked the following question in an interview:
Which of the following would you choose recommended when and where?
ArrayList<SomeType> a = new ArrayList<SomeType>(); or
List<SomeType> a = new ArrayList<SomeType>();
I dont know much difference if anyone knows kindly please help. Thanks in advance.
Second is better cause you can simply change underlying implementation from
ArrayListtoLinkedList(or to any proper implementation) by one line code change.