Java – why use interfaces?

An interface is a way to describe how to interact with a class that implements defined methods. An interface only defines how to interact with an interface or class that implements the interface, not the actual implementation. In other words, an interface exposes what behaviors will be available, not how the behavior is carried out. In the real world, all cars have horns, but each car’s horn may have a distinct volume, pitch, sound, and duration. The interface for each car may be the same (pressing the center of the steering wheel), but the sound produced by each car (the implementation) is different. This allows any driver to know how to use any car horn, not how the sound is produced by the internals of the car.

Continue reading Java – why use interfaces?