I am learning Java, I saw the following description regards to interface in a book:
When a variable is declared to be of an interface typ
You don't instantiate an interface. You create classes that implement the interface, instantiate those, but reference the interface (as opposed to the implementing class).
This allows your code to remain implementation-neutral, similar to using a List
reference, but an ArrayList
implementation.
When combined with dependency injection it makes testing and extensibility much easier, too.