Override abstract in a function
I want to add an extra parameter to send()
In DumpSequence.java:
private static Receiver sm_receiver = new DumpReceiver(System.out, true);
sm_receiver.send(message, lTicks); (Work)
sm_receiver.send(message, lTicks, addParam1); (Won't work)
DumnpReceiver.java I tried to add extra param which is lTimeStam开发者_Go百科p2:
public void send(MidiMessage message, long lTimeStamp, long lTimeStamp2) {...}
Error:
DumpSequence.java:136: send(javax.sound.midi.MidiMessage,long) in javax.sound.mi
di.Receiver cannot be applied to (javax.sound.midi.MidiMessage,long,long)
sm_receiver.send(message, lTicks, lTicks);
^
.\DumpReceiver.java:21: DumpReceiver is not abstract and does not override abstr
act method send(javax.sound.midi.MidiMessage,long) in javax.sound.midi.Receiver
public class DumpReceiver
^
2 errors
remove the @Override annotation from line 21
If you extend an abstract class it needs to define all the abstract method or it needs to be abstract class.
Or if you are overloading method then just remove @Override
annotation
See Also
- Method Overriding
If you want to call send(MidiMessage message, long lTimeStamp, long lTimeStamp2)
you need to use a DumpReceiver
instance, not a Receiver
one. There is no such method in `Receiver
private static DumpReceiver sm_receiver = new DumpReceiver(System.out, true);
EDIT: by inheritance, you can still use it as a plain Receiver
object.
You still have to implement send(javax.sound.midi.MidiMessage,long)
, even if you don't use it - it's required by the interface you implemented
精彩评论