📄 breathdemo.java
字号:
// 例 2.2.4 BreathDemo.java
class Animal // 定义一个Animal类
{
void breathe() // 动物的呼吸方法
{
System.out.println("animal breathe");
}
}
class Fish extends Animal // 鱼也是动物
{
}
class BreathDemo
{
public static void main(String args[])
{
Animal an = new Animal(); //创建Animal类的一个对象
Fish fh = new Fish(); //创建Fish类的一个对象
an.breathe(); //调用Animal类的breathe()方法
fh.breathe(); //调用Fish类的breathe()方法
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -