62,614
社区成员
发帖
与我相关
我的任务
分享
class A{
public static void main(){
System.out.println("学习了,联系下");
}
}
//生成四个字节码文件
enum Note {
MIDDLE_C,C_SHARP,B_FLAT;
}
class Instrument {
public void play(Note n) {
System.out.println("Instrument.play()");
}
}
class Wind extends Instrument {
public void play(Note n) {
System.out.println("Wind.play() "+n);
}
}
public class Music {
public static void tune(Instrument i) {
i.play(Note.MIDDLE_C);
}
public static void main(String args[]) {
Wind flute=new Wind();
tune(flute);
}
}
/*
Output:
Wind.play() MIDDLE_C
*/