You suggest:
I guess the following alternative was possible
public class RemoteControl<C extends Control<V>,V extends View> implements Control<V>{}
This is the correct solution, although I would normally write it as (for readability):
public class RemoteControl<V extends View, C extends Control<V>> implements Control<V>{}
You are typing RemoteControl
on a Control
object which is also typed on an object that extends View
. As such you need to provide the implementation of View
that types the Control
object that types your RemoteControl
object.
I guess you could interpret your question as saying, why do I have to provide V
- shouldn't it be implied from the <C extends Control<V>>
. To which, the answer is no, you need to provide a type for V
to ensure that the right type of Control
is provided (i.e. that it extends Control<V>
)
If you don't care what type View
the Control
object is typed on, you don't need to type Control
in the RemoteControl
:
public class RemoteControl<C extends Control> implements Control{}
However, the fact Control
is typed on V extends View
and RemoteControl implements Control<V>
, rather suggests that you do...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…