大家好,小弟是新人,想大家帮一下看看我这程序哪里出错了!
class Person{
private int age;
private String name;
public static void Person(int age, String name )
{
if(age>=0&&age<120)
{
this.age=age;
this.name=name;
}
}
}
class Students extends Person
{ super(age,name);
void study()
{
System.out.println(name+"is studying and his age is "+age);
}
}
class Worker
{
super(age,name);
void work()
{
System.out.println(name+"is working and his age is "+age);
}
}
class ExtendsExam
{
public static void main(String[] args)
{
Student p=new person();
Worker t=new Worker();
p.age=20;
p.name="lixiangzheng";
t.age=30;
t.name="chenglong";
p.study();
t.work();
}
}
编辑器上显示的错误是:
extendsexam.java:17: 错误: 需要';'
void study()
^
extendsexam.java:28: 错误: 需要<标识符>
class
^
2 个错误