小编Rol*_*and的帖子

Generic Generics:"令牌上的语法错误"扩展",预期"

public interface View{...

public interface Control<V extends View>{...

public class RemoteControl<C extends Control<V extends View>> implements Control<V>{...
Run Code Online (Sandbox Code Playgroud)

给我一个"令牌上的语法错误"扩展",预期"在RemoteControl类的"V extends View"上.

我想以下替代方案是可能的

public class RemoteControl<C extends Control<V>,V extends View> implements Control<V>
{...
Run Code Online (Sandbox Code Playgroud)

我仍然想知道这是否不能以更隐式的方式完成,因为后者需要View的冗余声明.即:

public class TVRemoteControl extends RemoteControl<TVControl,TvView> implements TVControl{...
Run Code Online (Sandbox Code Playgroud)

VS

public class TVRemoteControl extends RemoteControl<TVControl> implements TVControl{...
Run Code Online (Sandbox Code Playgroud)

也许我只是被困在一个盒子里,但是有可能以更优雅的方式获得"泛型泛型"

java generics

7
推荐指数
1
解决办法
7249
查看次数

标签 统计

generics ×1

java ×1