继承:
* 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中文网其他相关文章!