0

In my code I have an interface Component to define types. I want to extend that interface with a class InputComponent that has to implement the framework of an API's InputListener.

I'm really at a loss and don't know what to do. To clarify:

public class InputListener implements EventListener {} // this is the API's implementation (details hidden)

public interface Component {}
public interface InputComponent extends Component implements XYZ {} // this should somehow work with the InputListener class

Could somebody give me some resources (links, information, anything at all) on how to do this?

5
  • An interface is a design-by-contract approach. Also it represents a has-a relationship. Why do you think it necessary to extend an interface? Makes no sense at all. Commented Mar 24, 2015 at 18:15
  • I want to use a List<Component> and put all the components in there. Is there no way to do this, considering the problem above? Commented Mar 24, 2015 at 18:18
  • Component is an interface. So creating a list of components means you can add classobjects to that list that "implements Component" Commented Mar 24, 2015 at 18:21
  • Thank you very much. I think I tried to approach the problem in a wrong way. Commented Mar 24, 2015 at 18:24
  • If you want, the web is full with tutorials on has-a and is-a relations in OOP Commented Mar 24, 2015 at 18:28

1 Answer 1

1

Interfaces can only extend other interfaces.

Interfaces cannot extend classes.

Interfaces do not implement other interfaces.

Sign up to request clarification or add additional context in comments.

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.