首頁 >Java >java教程 >日繼承:

日繼承:

Barbara Streisand
Barbara Streisand原創
2024-12-31 06:44:10305瀏覽

繼承:

 * Inheritance is implemented using the extends keyworrds.

 * Inheritance in java is a mechanism where one class child or subclass acquires the properties and behaviors fields and methods of another class parent or superclass.

 * subclass (child) - the class that inherits from another class

 * superclass (parent) - the class being inherited from To inherit from a class, use the extends keyword. # 

範例程式:

package reegan;
class Dad

{
int 錢=2000;
}
班級兒子延伸爸爸
{

}
公開課主課
{
public static void main(String []args)
{
子 s1=新兒子();
System.out.println(s1.money);
}
}

日繼承:

以上是日繼承:的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn