📄 instrumenttest.java
字号:
package s2Java.sg.ch02.exercise;
class Instrument{
public void play(){}
}
class Piano extends Instrument{
public void play(){
System.out.println("使用钢琴演奏!");
}
}
class Violin extends Instrument{
public void play(){
System.out.println("使用小提琴演奏!");
}
}
public class InstrumentTest {
public void testPlay(Instrument ins){
ins.play();
}
public static void main(String[] args){
InstrumentTest test = new InstrumentTest();
test.testPlay(new Piano());
test.testPlay(new Violin());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -