What are the restrictions on static methods in a generic class?
Posted on 2011-09-20
I'm trying to understand this paragraph in my book. I guess this means that in a class like MyClass<T>, a static method cannot refer to T. Is that correct? Why are other methods allowed to refer to T while static methods are not?
"In a generic class, static methods and fields cannot refer to the class's type variables, since, after erasure, there are no type variables. Further, since there is only one raw class, static fields are shared among the class's generic instantiations"