What does Java's type parameter wildcard really mean? What's the real difference between Foo and Foo<?>?

后端 未结 5 1004
清酒与你
清酒与你 2021-01-05 02:32

For a generic interface:

public interface Foo {
    void f(T t); 
} 

The difference between the two fields:

publ         


        
5条回答
  •  青春惊慌失措
    2021-01-05 02:47

    Object is the supertype of all types in java. However, Foo is not the supertype of all Foo. The supertype of all Foo is Foo. see http://docs.oracle.com/javase/tutorial/extra/generics/wildcards.html for more details.

提交回复
热议问题