lauqasim 2016-01-20 11:46 采纳率: 0%
浏览 1775

java程序在eclipse运行下出错,但是在cmd可以正常运行,求大神!

源代码:
class Person{
private String name;
private String location;

Person(String name){
    this.name = name;
    location = "beijing";
}

Person(String name,String location){
    this.name = name;
    this.location = location;
}

public String info(){
    return "name:"+name+"location:"+location;
}

}

class Student extends Person {
private String school;
Student(String name,
String school) {
this(name,"beijing", school);
}
Student(String n,String l,String school) {
super(n,l);
this.school = school;
}
public String info() {
return super.info()+
" school: "+school;
}
}

class Teacher extends Person{
private String capital;

Teacher(String name,String capital){
    this(name,"beijing",capital);
}

Teacher(String n,String l,String capital){
    super(n,l);
    this.capital = capital;
}

public String info(){
    return super.info()+"location"+capital;
}

}

public class TestTeacher {
public static void main(String[] args) {
Person p1 = new Person("A");
Person p2 = new Person("B","shanghai");
Student s1 = new Student("C","S1");
Student s2 = new Student("C","shanghai","S2");
System.out.println(p1.info());
System.out.println(p2.info());
System.out.println(s1.info());
System.out.println(s2.info());

    Teacher t1 = new Teacher("D","Professor");
    System.out.println(t1.info());
}

}

错误:
Exception in thread "main" java.lang.NoSuchMethodError: Person.(Ljava/lang/String;)Vat TestTeacher.main(TestTeacher.java:55)

  • 写回答

8条回答 默认 最新

  • threenewbee 2016-01-20 11:50
    关注

    person构造函数前面加上public

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?