哪位高人,帮我看看这程序啦~~~~呵呵
第35、36 行出错了 为什么呢?怎么改过来。
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Administrator
*/
public 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,school,"beijing");
}
Student(String n,String l,String school){
super(n,l);
this.school = school;
}
public String info(){
rerurn super.info()+"school:"+school;
}
}
class Tsest{
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());
}
}
------解决方案-------------------- 探讨 第35 36 行 public String info(){ rerurn super.info()+"school:"+school; 好像有点麻烦 得麻烦网友们复制到自己的电脑中运行才知道。。。。。
------解决方案-------------------- 词写错了,是return,不是rerurn
探讨 第35 36 行 public String info(){ rerurn super.info()+"school:"+school; 好像有点麻烦 得麻烦网友们复制到自己的电脑中运行才知道。。。。。
------解决方案-------------------- rerurn ?
return !
------解决方案--------------------
呵呵,错谁都会犯,下次多注意些就行了,
而且光看这个类,应该运行没结果吧。。。