ArrayList aList = new ArrayList();
List aList = new ArrayList();
What\'s the difference between these two and which is better to use and why?
Both are deprecated since Java 1.5.
It should be:
List list = new ArrayList();
// or whatever data type you are using in your list
Please read Effective Java by Joshua Bloch, especially these two items:
BTW, if you use Guava, you have a factory method for constructing an ArrayList so you don't have to repeat the type parameter:
List list = Lists.newArraylist();