I'll take your comment as the actual question:
If I create a new instance of GenericClass like this: new GenericClass then will the interface it implements also be GenericInterface and will the inner class als be AnotherClass
Yes, it's gonna be GenericInterface<Integer>
. No, it's not gonna be AnotherClass<Integer>
.
class GenericClass<T>
introduces a type-parameter T
that can be used e.g. with a generic interface
like you do. Now be careful: class AnotherClass<T>
that is nested within GenericClass
introduces another type-parameter T
that hides the one that GenericClass
has introduced.
If you want AnotherClass
to use T
of GenericClass
, then simply skip the <T>
for AnotherClass
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…