List versus ArrayList as reference type?

If you use the first form, you are saying all you are ever going to use is the functionality of the List interface – nothing else, especially nothing extra added by any implementation of it. This means you can easily change the implementation used (e.g. just substitute LinkedList for ArrayList in the instantiation), and not worry about it breaking the rest of the code because you might have used something specific to ArrayList.

Leave a Comment