开发者

Extending class with generic parameter

开发者 https://www.devze.com 2023-03-07 14:24 出处:网络
I need to derive from the following class: public abstract class MyTool<VIEW extends MyView> implements LookupListener, MouseListener, MouseMotionListener, KeyListener {}

I need to derive from the following class:

public abstract class MyTool<VIEW extends MyView>
  implements LookupListener, MouseListener, MouseMotionListener, KeyListener {}

The following does not work:

public abstract class MyS开发者_开发问答ubTool<VIEW> extends MyTool<VIEW> {}

Thanks !


The compiler in MySubTool as no way of knowing that VIEW in MySubTool is a subclass of MyView, you have to specify it again:

public abstract class MySubTool<VIEW extends MyView> extends MyTool<VIEW> {}


This should:

public abstract class MySubTool<VIEW extends MyView> extends MyTool<VIEW> {}
0

精彩评论

暂无评论...
验证码 换一张
取 消