Java Reference
In-Depth Information
4.3. Extending Interfaces
Interfaces can be extended using the
extends
keyword. Interfaces, unlike
classes, can extend more than one other interface:
public interface SerializableRunnable
extends java.io.Serializable, Runnable
{
// ...
}
The
SerializableRunnable
interface extends both
java.io.Serializable
and
Runnable
, which means that all methods and constants defined by those
interfaces are now part of the
SerializableRunnable
contract, together with
any new methods and constants it defines. The interfaces that are exten-
ded are the
superinterfaces
of the new interface and the new interface is
a
subinterface
of its superinterfaces.
Because interfaces support multiple inheritance, the inheritance graph
can contain multiple paths to the same superinterface. This means that
constants and methods can be accessed in different ways. However, be-
cause interfaces define no implementation of methods, and provide no
per-object fields, there are no issues regarding the semantics of this form
of multiple inheritance.
4.3.1. Inheriting and Hiding Constants
An extended interface inherits all the constants declared in its superint-
erfaces. If an interface declares a constant of the same name as an in-
herited constant, regardless of their types, then the new constant hides
the inherited one; this is the same hiding of fields described in "
Hiding
the subinterface, any reference to the constant using its simple name will
refer to the constant defined in the subinterface. The inherited constant
can still be accessed with the qualified name of the constant, that is, the