【发布时间】:2010-12-09 23:35:25
【问题描述】:
这里是受保护方法的文档:
/** Converts jmusic score data into a MIDI Sequence */
protected javax.sound.midi.Sequence scoreToSeq(Score score)
我做了这个小类来扩展 scoreToSeq 方法来自的类:
public class MidiSequence extends MidiSynth{
public Sequence getSequence(Score score){
MidiSynth synth = new MidiSynth();
Sequence sequence = null;
try
{
// Here I get the error saying that the method has
// protected access in MidiSynth
sequence = synth.scoreToSeq(score);
}
catch (InvalidMidiDataException e)
{
/*
* In case of an exception, we dump the exception
* including the stack trace to the console.
* Then, we exit the program.
*/
e.printStackTrace();
System.exit(1);
}
return sequence;
}
}
【问题讨论】:
-
来自 Najib Tounsi(没有足够的代表发表评论):尽管,
synth.scoreToSeq(score);应该是合法的。
标签: java inheritance protected