This is more of a documentation than a real question. This does not seem to have been addressed on SO yet (unless I missed it), so here goes:
Imagine a generic class
C# implementation of generics is more closer to C++. In both of these languages MyClass
and MyClass
don't share static members but in Java they do. In C# and C++ MyClass
internally creates entirely new type at compile time as if generics are kind of macros. You can usually see their generated names in stack trace, like MyClass'1
and MyClass'2
. This is why they don't share static variables. In Java, generics are implemented by more simpler method of compiler generating code using non-generic types and adding type casts all over. So MyClass
and MyClass
don't generate two entirely new class in Java, instead they both are same class MyClass
underneath and that's why they share static variables.