Java Reference
In-Depth Information
freely generify methods independently of clients that define subclasses or subinter-
faces of the library.
Consider the example:
class CollectionConverter {
List toList(Collection c) {...}
}
class Overrider extends CollectionConverter {
List toList(Collection c) {...}
}
Now, assume this code was written before the introduction of generics, and now the
author of class CollectionConverter decides to generify the code, thus:
class CollectionConverter {
<T> List<T> toList(Collection<T> c) {...}
}
Without special dispensation, Overrider.toList would no longer override CollectionConvert-
er.toList . Instead, the code would be illegal. This would significantly inhibit the use of
generics, since library writers would hesitate to migrate existing code.
8.4.3. Method Modifiers
MethodModifiers:
MethodModifier
MethodModifiers MethodModifier
MethodModifier: one of
Annotation public protected private abstract
static final synchronized native strictfp
If an annotation a 9.7 ) on a method declaration corresponds to an annotation type T
9.6 ) , and T has a (meta-)annotation m that corresponds to java.lang.annotation.Target , then m
must have an element whose value is java.lang.annotation.ElementType.METHOD , or a compile-
time error occurs.
It is a compile-time error if the same modifier appears more than once in a method declar-
ation, or if a method declaration has more than one of the access modifiers public , protected ,
and private 6.6 ) .
It is a compile-time error if a method declaration that contains the keyword abstract also
contains any one of the keywords private , static , final , native , strictfp , or synchronized .
Search WWH ::




Custom Search