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 thewatchStock
method in theStockMonitor
class 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, TickerSymbol tickerSymbol, BigDecimal delta) { ... } }StockWatcher
interface can register to be notified of stock value changes.StockWatcher
objects are guaranteed to have avalueChanged
method.
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Copyright 1995-2005 Sun Microsystems, Inc. All rights reserved.