出现异常错误:- 此处不允许使用“void”类型
import javax.sound.midi.*;
public class MiniMusicPlayer1 {
public static void main(String[] args) {
try {
Sequencer player = MidiSystem.getSequencer();
Sequence seq = new Sequence(Sequence.PPQ, 4);
Track track = seq.createTrack();
for (int i = 5; i < 61; i += 4) {
track.add(makeEvent(144, 1, i, 100, i));
track.add(makeEvent(128, 1, i, 100, i));
}
player.setSequence(seq);
player.setTempoInBPM(220);
player.start();
} catch (Exception ex) {
System.out.println(ex.printStackTrace());
}
}
public static MidiEvent makeEvent(int comd, int ch, int note, int vel,
int tick) {
MidiEvent event = null;
try
{
ShortMessage a = new ShortMessage();
a.setMessage(comd, ch, note, vel);
event = new MidiEvent(a,tick);
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
return event;
}
ankit@battlestar:/home/mount_150/Java$ javac MiniMusicPlayer1.java MiniMusicPlayer1.java:21: error: 'void' type not allowed here System.out.println(ex.printStackTrace()); ^
请帮忙。