Interfaces still get me! I have a class ClassOne...
And then I have another class, ClassTwo.
I'd like to obtain a Sequencer instance of ClassOne, but does ClassOne need to implement the entire Sequencer interface (i.e. every single method) for this to be made (http://java.sun.com/j2se/1.5.0/docs/api/javax/sound/midi/Sequencer.html)? I hoped that by calling MidiSystem.getSequencer() in ClassOne this would be suffice for ClassTwo's code to work, but I get the error "cannot find symbol" for 'new ClassOne()'.
What ought I be doing to get the Sequencer instance of ClassOne?
Ravaa Bal wrote:Hey guys, I have an issue with interfaces in general (didn't want to create a new topic for it).
If say I wanted to implement Sequencer after all like so:
First, don't do this. Your getLoopCount() will call getLoopCount() which will call getLoopCount() which will... you get the idea. An infinite recursive loop. What do you really want getLoopCount() to return?
Why do I get an error highlighting the implement line saying something like this?
"ClassOne is not abstract and does not override abstract method setLoopCount(int) in ...etc etc... Sequencer"
Looks like the method defined in the interface is:
And you are implementing a method like:
These aren't the same method. What is the difference? How do you fix it?