Content deleted Content added
m Reverted 1 edit by 168.167.96.30 identified as test/vandalism using STiki |
|||
Line 5:
One benefit of using interfaces is that they simulate [[multiple inheritance]]. All classes in Java must have exactly one [[base class]], the only exception being {{Javadoc:SE|package=java.lang|java/lang|Object}} (the [[top type|root class]] of the Java [[type system]]); [[multiple inheritance]] of classes is not allowed. However, an interface may inherit multiple interfaces and a class may implement multiple interfaces.
== Overview ==
Interfaces are used to encode similarities which the classes of various types share, but do not necessarily constitute a class relationship. For instance, a [[human]] and a [[parrot]] can both [[whistle]]; however, it would not make sense to represent <code>Human</code>s and <code>Parrot</code>s as subclasses of a <code>Whistler</code> class. Rather they would most likely be subclasses of an <code>Animal</code> class (likely with intermediate classes), but both would implement the <code>Whistler</code> interface.
|