开发者

Concrete class as generic param

Is there any difference between those definitions?

 public class开发者_JS百科 Foo<String> {}
 public class Foo{}

UPDATED Can first one have any real usage?


Yes, the first is equivalent to Foo<T> but with the type parameter named String (which is not java.lang.String) instead of T. So you aren't actually using a concrete class as the type parameter (that isn't legal... try changing the declaration to class Foo<java.lang.String>).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜