Java Reference
In-Depth Information
should clearly document why the "unchecked" warning is occurring and
why you are certain that the lack of a runtime type check is not a prob-
lem.
[4] Implementing a clone method is one such circumstancesee Section A.3.2 on page 747 .
11.5.2. Overloading and Overriding
In Chapter 2 we defined overloaded methods to be methods having the
same name but different signatures. Later, in Chapter 3 , we defined an
overriding method to be a method in a subclass with the same name
and the same signature as an accessible method in the supertype. When
a method signature involves type variables, these definitions have to be
adapted slightly.
First, the definition of "same signature" for two generic methods re-
quires that they have the same number of type variables with the same
corresponding bounds. Further, after all the uses of the type variables
in the second method are renamed with the names of the type variables
from the first method, the formal parameter types must be the same.
Second, rather than requiring the same (or different) signatures we talk
about override-equivalent signatures: Two methods have override-equi-
valent signatures if their signatures are the same, or if the erasures of
their signatures are the same.
Using the new definitions, two methods are overloaded if they have the
same name and do not have override-equivalent signatures. Consider
this class:
class Base<T> {
void m(int x) {}
void m(T t) {}
void m(String s) {}
<N extends Number> void m(N n) {}
void m(SingleLinkQueue<?> q) {}
}
 
 
Search WWH ::




Custom Search