3

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 MySubTool<VIEW> extends MyTool<VIEW> {}

Thanks !

2 Answers 2

3

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> {}
Sign up to request clarification or add additional context in comments.

3 Comments

Here is what the compiler reports: cannot find symbol symbol : constructor MyView() location: class com.mysystem.viewer.MyView<VIEW> public MySubTool() {
This is unrelated to your previous problem, which was about generics. Your new problems is about constructors. Your base class has no default constructors, so you have to specify in MySubTool which constructor you want to call using super.
oops sorry for the noise. Thanks for your great help !
1

This should:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.