June 2004
Intermediate to advanced
848 pages
21h 28m
English
So far we've discussed examples of the Comparable and Cloneable interfaces. These interfaces solve compile time issues of forcing a class to have certain behavior. There is an additional way that an interface can be used, to obtain more dynamic behavior. It forms the basis of GUI programming in Java. We have already seen most of this; the only piece that's new is the way that the object-which-implements-an-interface tells the servicing class about itself.
In our earlier example, we called a service method and passed an instance of our handler object as an argument:
Depot.service( myPlane );
Inside the body of service, the method myPlane.refuel() was immediately called back, and that really ...
Read now
Unlock full access