This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
What is it you don't understand ? Most people will just post something similar to what is in the articles you have read. If you tell us which particular part you don't understand, you will likely get a more useful answer.
Program to an Interface not to an Implementation means program to a supertype. It means, the declared type of the variable should be a supertype usually an abstract class or Interface. The object assigned to the variable can be any of the concrete implementation of the supertype. Check the following example given below.
The class [b] MainApp does not need to know
Joined: May 03, 2004
Please continue from here
i.e. The MainApp does not need to know about the actual object types.
I'll try, though it does tend to cause confusion when several people reply simultaneously.
You declare in terms of the superclass (or better in terms of the interface) and when you instantiate the subclass you can be sure of a certain set of methods available. You use that set, which are the same as the interface.
If you wish to change the implementation you can alter the instantiated type.
You can change that last bit to new LinkedList<String>() secure in the knowledge the program will still work.