More Features of the Java Language |
Sleeper
Interface
Implementing an Interface in the previous lesson already showed you how to implement an interface. Here, theGUIClock
class implements one interface--Sleeper
:Remember that when a class implements an interface, it is essentially signing a contract. The class must provide method implementations for all of the methods declared in the interface and its superinterfaces. Or, the class must be declaredpublic class GUIClock extends Applet implements Sleeper { . . . public void wakeUp() { // update the display } }abstract
. The method signature (the name and the number and type of arguments) for the method in the class must match the method signature as it appears in the interface.
More Features of the Java Language |