Take the List
interface, for instance. You can decide at only one point whether you want to use an ArrayList
or a LinkedList
(or something else related) for a specific occasion.
Yet they both implement the List
interface. So, no matter how they work or whether they're even related hierarchically, it is guaranteed that they expose a set of methods you can use and you don't have to know at every point in your code the implementation behind the collection object you end up with.