一只早起的虫 2016-10-09 02:39 采纳率: 0%
浏览 9733
已采纳

Exception in thread "main" java.lang.Error

package com.dlhs;
class Person(){

public void setName(String name){
    this.name=name;
}
public void setAge(int age){
    this.age=age;
}
public return String getName(){
    return name;
}
public return  int getAge(){
    return age;
}

}

class Student extends Person()
{

public return String getSchool(){
return school;
}
public void setSchool(String school){
this.school =school;
}
}
public class Test{
public static void main(String args[]){
public String school;
public String name;
public int age;
Student student =new Student();
student.setName("john");
student.setAge(18);
student.setSchool("SCH");
System.out.println(student.getName());
System.out.println(student.getAge());
System.out.println(student.getSchool());}

}

  • 写回答

3条回答 默认 最新

  • 全栈极简 博客专家认证 2016-10-09 03:14
    关注

    Unresolved compilation problem: 没有解决的编译问题

    你的代码有语法错误,根本不能通过编译。

    问题:
    1、class Person后面不需要(),而且首字母要大写,对应的文件名也要大写
    2、public return String getName() 这种方法不需要return,全部都要去掉。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?