Suppose I have two classes:
abstract class GenericA<E> {
public void go(E e) {...}
}
public class IntegerA extends GenericA<Integer> {
}
Note that GenericA
is package-private and generic, and IntegerA
is public and not generic.
Now, when I generate the public Javadoc (using Eclipse), I see the following in the IntegerA
methods section:
public void go(E e)
The problem is that a reader of that Javadoc has no idea what E
is; i.e., that E
represents Integer
. I would rather have the Javadoc say
public void go(Integer e)
Is there a way to make Javadoc behave the way I want it to?
In this post, We will discuss some very interesting points about generic classes and their inheritance. A generic class can extend a non-generic class.
Generic Classes and SubtypingYou can subtype a generic class or interface by extending or implementing it. The relationship between the type parameters of one class or interface and the type parameters of another are determined by the extends and implements clauses.
Yes, you can use any valid Java identifier for type parameters.
Whenever you want to restrict the type parameter to subtypes of a particular class you can use the bounded type parameter. If you just specify a type (class) as bounded parameter, only sub types of that particular class are accepted by the current generic class. These are known as bounded-types in generics in Java.
Only way I know is override method in IntegerA
with Integer and then call super method.
@Override
public void go(Integer e) {
super.go(e);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With