Vishal Hegde wrote:Ritchie sir , arent both correct?
i mean
ArrayList<Integer>a=new ArrayList<Integer>(); //as arraylist is a class
List<Integer>iList=new ArrayList<Integer>(); //list is an interface
Campbell's solution is best. It is my understanding that
you should always code to an interface (when possible) and not its implementation.
I think this allows for greater flexibility if you need to change something down the line.