首页 >Java >java教程 >日继承:

日继承:

Barbara Streisand
Barbara Streisand原创
2024-12-31 06:44:10295浏览

继承:

 * 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