There is a principle that states: "Always program the interface, not the implementation." LinkedList is an implementation of the List interface. That is, List simply indicates what List can do, but does not say how it does it.
The LinkedList class “obeys” the specification of the list, and as such, when we write programs, we can depend on the LinkedList, which behaves exactly as specified in the List. This makes programs more reliable, because if you decide to use a different List type, say ArrayList, then your program code will not change, because you are not dependent on the details of the List implementation.
When you declare a variable as in
List myList;
The list type is called the "visible" type. That is, the compiler will treat myList as a list in the rest of your code. You cannot refer to any function myList, which is not included in the List specification (without casting and violation of the principle).
When you instantiate an object, as in
= new LinkedList();
The LinkedList type is known as the "actual type". The compiler does not care about this so much. This only matters at runtime.
source share