S
Stefan Ram
I believe that
java.lang.Comparable< ? >
means that any java.lang.Comparable type can be accepted.
The type parameter might also be named as in
< T > ........ final java.lang.Comparable< T >
, but I believe that this also allows any
java.lang.Comparable type, just that it is named »T«.
Then why is the following SSCCE not possible?
interface Alpha { void alpha( final java.lang.Comparable< ? >x ); }
class Beta implements Alpha
{ public< T >void alpha( final java.lang.Comparable< T >x ){} }
public class Main
{ public static void main( final java.lang.String[] args ){} }
Main.java:3: Beta is not abstract and does not override abstract method alpha(java.lang.Comparable<?>) in Alpha
class Beta implements Alpha
^
1 error
java.lang.Comparable< ? >
means that any java.lang.Comparable type can be accepted.
The type parameter might also be named as in
< T > ........ final java.lang.Comparable< T >
, but I believe that this also allows any
java.lang.Comparable type, just that it is named »T«.
Then why is the following SSCCE not possible?
interface Alpha { void alpha( final java.lang.Comparable< ? >x ); }
class Beta implements Alpha
{ public< T >void alpha( final java.lang.Comparable< T >x ){} }
public class Main
{ public static void main( final java.lang.String[] args ){} }
Main.java:3: Beta is not abstract and does not override abstract method alpha(java.lang.Comparable<?>) in Alpha
class Beta implements Alpha
^
1 error