I'm defining a class:
class Foo> {
}
the compiler is complaining about I being hidden by I. I guess the second time I appears in the definition is hiding in scope the first one, as if variable I could be assigned to two different types. How to do it correctly?
Edit:
this is an inner class. the full code can be:
class Baz {
class Foo> {
}
}
now the problem is that if I re-nominate inner I to J, i'm not sure that I and J are actually the same types.
解决方案
Don't make the inner class parameterized:
class Baz> {
class Foo {
}
}
As an inner (non-static nested) class, I as defined in the Baz declaration will still have meaning in Foo, since every Foo will have an implicit reference to its outer Baz instance.