यहाँ संरक्षित विधि के लिए दस्तावेज़ है:मैं सुरक्षित जावा विधि तक क्यों नहीं पहुंच सकता हूं, मैंने सोचा कि मैंने कक्षा को बढ़ाया है?
/** 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;
}
}
नजीब तोउन्सी (टिप्पणी करने के लिए पर्याप्त प्रतिनिधि नहीं): हालांकि, 'synth.scoreToSeq (स्कोर); 'कानूनी होना चाहिए। –