Java Reference
In-Depth Information
class RemoteEventService extends AbstractEventService {
/* ... */
}
Or you might define a generic service for different kinds of events:
class LocalEventService<T extends Event> extends
AbstractEventService { /* ... */ }
The possibilities really depend on the semantics of the types involved.
When choosing to extend a parameterized type, you need to carefully
consider the implications, particularly if you are implementing an inter-
face, because a class cannot inherit two interface types that are differ-
ent parameterizations of the same interface. For example, consider the
Comparable interface. If you define a comparable class Value then it is nat-
ural to declare it as:
class Value implements Comparable<Value> {
// ...
}
Suppose you now extend Value to add additional state. This ExtendedValue
class should define objects that are comparable only to ExtendedValue ob-
jects, so you would expect to be able to define it so:
class ExtendedValue extends Value
implements Comparable<ExtendedValue> { // INVALID!
// ...
}
 
Search WWH ::




Custom Search