Solution (source code)

= Solution

A collections library can specify a `List<E>` <Java interface>, with different implementations such as `ArrayList<E>` and `LinkedList<E>`. A method accepting `List<E>` can iterate or access elements according to the documented list contract without requiring one particular storage representation. Each implementation may also extend its own appropriate class superclass.

\b[The benefit is separating a usable contract from its implementation.] A parameter restricted to a concrete `ArrayList<E>` would exclude a <linked list> implementation and unnecessarily expose the storage choice. Requiring all providers to extend one concrete class would couple them to its implementation and consume <Java>'s single class-inheritance relationship. Interfaces permit multiple implemented contracts, though clients must rely on the stated contract rather than assuming every optional operation is supported or has the same <time complexity>.