开发者

Concrete class as generic param

开发者 https://www.devze.com 2023-03-09 07:35 出处:网络
Is there any difference between those definitions? public class开发者_JS百科 Foo<String> {}

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

精彩评论

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