java generic parameterized type
Sorry for this simple question
In this class
class GenericTest{
static <T> List<T> getList(List<T> list){
return list;
}
}
why this this <T>
just after static needed in the declaration. I thought th开发者_开发百科e return type List<T
> is fine.
You are declaring that this method has a type parameter "T". If you didn't declare it then there is no way for the compiler to know what type you're talking about (T is not declared anywhere else).
精彩评论