class Person
{
String name;
int age;
}
class Student extends Person
{
void Stuby()
{
System.out.println("good good studdy");
}
}
class Worker extends Person
{
void work()
{
System.out.println("hard work");
}
}
class ExtendsDemo
{
public static void main(String[] args)
{
Student stu = new Student ();
stu.name = "xiaoqiang";
stu.age = 12;
stu.study();
}
}
============================
---------- javac ----------
ExtendsDemo.java:52: 错误: 找不到符号
stu.study();
^
符号: 方法 study()
位置: 类型为Student的变量 stu
1 个错误
输出完成 (耗时 0 秒) - 正常终止 |