S
Stefan Ram
I have defined a signature in an interface:
void addrac
( java.lang.Comparable< ? >container,
int position );
. I implemented this as follows in a class:
public void addrac
( final java.lang.Comparable< ? >container,
final int position )...
. This worked fine, until I needed to refer to the type »?«
within the body of the method. I tried to give it a name:
public< T >void addrac
( final java.lang.Comparable< T >container,
final int position )...
. But now Java tells me that this does *not* override the
method of the interface.
One step back in time: Actually, I started from this interface:
void addrac
( java.lang.Comparable container,
int position );
I inserted the »< ? >« only to get rid of a »rawtype« warning.
So what would be a good way to get rid of such »rawtype«
warnings, but also allow implementations to refer to the
type name in their body, when they need this? (Or how can
I get such a reference while still implementing the
signature of the interface?)
void addrac
( java.lang.Comparable< ? >container,
int position );
. I implemented this as follows in a class:
public void addrac
( final java.lang.Comparable< ? >container,
final int position )...
. This worked fine, until I needed to refer to the type »?«
within the body of the method. I tried to give it a name:
public< T >void addrac
( final java.lang.Comparable< T >container,
final int position )...
. But now Java tells me that this does *not* override the
method of the interface.
One step back in time: Actually, I started from this interface:
void addrac
( java.lang.Comparable container,
int position );
I inserted the »< ? >« only to get rid of a »rawtype« warning.
So what would be a good way to get rid of such »rawtype«
warnings, but also allow implementations to refer to the
type name in their body, when they need this? (Or how can
I get such a reference while still implementing the
signature of the interface?)