|
|
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
When you define a new interface, you are defining a new reference data type. You can use interface names anywhere you can use any other data type name. Recall that the data type for the first argument to thewatchStockmethod in theStockMonitorclass isStockWatcher:Only an instance of a class that implements the interface can be assigned to a reference variable whose type is an interface name. So only instances of a class that implements thepublic class StockMonitor { public void watchStock(StockWatcher watcher, String tickerSymbol, double delta) { ... } }StockWatcherinterface can register to be notified of stock value changes.StockWatcherobjects are guaranteed to have avalueChangedmethod.
|
|
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Copyright 1995-2004 Sun Microsystems, Inc. All rights reserved.