?? testinherit.java
字號:
/**
* Description:
* <br/>Copyright (C), 2005-2008, Yeeku.H.Lee
* <br/>This program is protected by copyright laws.
* <br/>Program Name:
* <br/>Date:
* @author Yeeku.H.Lee kongyeeku@163.com
* @version 1.0
*/
class Animal
{
private void beat()
{
System.out.println("心臟跳動...");
}
public void breath()
{
beat();
System.out.println("吸一口氣,吐一口氣,呼吸中...");
}
}
//繼承Animal,直接復用父類的breath方法
class Bird extends Animal
{
public void fly()
{
System.out.println("我在天空自在的飛翔...");
}
}
//繼承Animal,直接復用父類的breath方法
class Wolf extends Animal
{
public void run()
{
System.out.println("我在陸地上的快速奔跑...");
}
}
public class TestInherit
{
public static void main(String[] args)
{
Bird b = new Bird();
b.breath();
b.fly();
Wolf w = new Wolf();
w.breath();
w.run();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -