EE3206 / EE5805 Java Programming and Applications
interface inheritance
In the java textbook, Liang(2009), p.397, "You can use an interface as a data type for a variable, as the result of casting and so on."
"You can now use the Edible interface to specify whether an object is edible.
The relationship between the class and the interface is known as interface inheritance.
Since interface inheritance and class inheritance are essentially the SAME, we will simply refer to both as inheritance. "
eg:
...
if (objects[i] instanceof Edible)
System.out.println(( (Edible) objects[i] ).howToEat() );
Keine Kommentare:
Kommentar veröffentlichen