|
|
|
|
Superinterfaces and SubinterfacesAs we have said, a class may implement zero or more interfaces. In addition, an interface may inherit (keyword interface BaseColors
{
int RED = 1, GREEN = 2, BLUE = 3;
}
interface RainbowColors extends BaseColors
{
int YELLOW = 3, ORANGE = 5, INDIGO = 6, VIOLET = 7;
}
interface PrintColors extends BaseColors
{
int YELLOW = 8, CYAN = 16, MAGENTA = 32;
}
interface FancyColors extends RainbowColors, PrintColors
{
int FUCHSIA = 17,
VERMILLION = 43,
CHARTREUSE = RED + 90;
}
Note: Be careful with ambiguous inherited fields (YELLOW, above)! The interfaces named in the extends clause for a class are the direct superinterfaces for that class. Any class that implements the declared interface is also considered to implement all the interfaces that this interface extends and that are accessible to the class.
|
|
This page was last modified on 02 October, 2007 |