I’m defining a class:
class Foo<I extends Bar & Comparable<I>> {
}
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<I> {
class Foo<I extends Bar & Comparable<I>> {
}
}
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:
As an inner (non-static nested) class,
Ias defined in theBazdeclaration will still have meaning inFoo, since everyFoowill have an implicit reference to its outerBazinstance.