The reason you can do this is to create more robust designs. Take, for example, the Java Framework collection. You have a List interface, and you have two implementations: ArrayList and LinkedList.
You can write your program specifically for using LinkedList or specifically for ArrayList. However, your program depends on these specific implementations.
, , List, List. , , - , :
public void doSomething(ArrayList a){}
ArrayList, LinkedList. , LinkedList? ? .
public void doSomething(List l){}
.
- , . List .
.