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>
).
精彩评论