This point comes up at least once a week. It is called "program to the interface."
There is a List interface, which you can find in the
Java™ API; it contains the names of all the methods in Lists. If you say you want a List, that is what you get. You can later say you want a particular implementation, and in the standard API you get these implementations:
AbstractList, AbstractSequentialList, ArrayList, AttributeList, CopyOnWriteArrayList, LinkedList, RoleList, RoleUnresolvedList, Stack, Vector
If you declare myList to be of type "List" you can change the implementation to anything which implements it (maybe not those called abstract) confident that your application will still work. You can swap an ArrayList for a LinkedList, for example.
If you do a search on JavaRanch for "program to the interface" you get several other discussions: two recent examples are
here and
a totally useless example, since I was involved :wink: . There is bound to be lots more available if you Google for "program to the interface."