i have following java class multiple level of inheritance type parameters. want use type parameter t in class b.
class b extends c { } class c<t extends d> { } class d { }
however, following doesn't compile:
class b extends c { t t; } class c<t extends d> { } class d { }
although can define variable t in class c, not coding practice. how can define following (this doesn't compile well)?
class b extends c<t extends d> { }
thanks!
type parameters not inherited!
if want have class b
generic, should specify own type parameter:
class b<t extends d> extends c<t> { t t; ... }
note must again constrain type parameter t
have extending d
because constrained way in class c
.