java吧 关注:1,231,046贴子:12,695,357
  • 8回复贴,共1

新手,请各位看看,我这里编译成功,语法没问题,就是运行不OK

取消只看楼主收藏回复

class Person {
private String name;
private int age;
public void setName(String name){
this.name=name;
}
public void setAge(int age){
this.age=age;
}
public String getName(){
return name;
}
public int getAge(){
return age;
}
public String getInfo(){
return "Name:"+name+"\n"+"Age:"+age;
}
}
class Student extends Person{
private String school;
public String getSchool(){
return school;
}
public void setSchool(String school){
this.school=school;
}
public String getInfo(){
return "Name:"+getName()+"\nAge:"+getAge()+"\nSchool:"+getSchool();
}
}
public class TextOverWrite
{
public static void main(String args[])
{
Student student = new Student();
Person person = new Person();
person.setName("none");
person.setAge(1000);
student.setName("job");
student.setAge(18);
student.setSchool("SCH");
System.out.println(person.getInfo());
System.out.println(student.getInfo());
}
}


1楼2017-09-05 19:39回复


    来自手机贴吧4楼2017-09-05 19:43
    回复
      自己顶


      来自手机贴吧6楼2017-09-05 19:47
      回复
        自己顶


        来自手机贴吧7楼2017-09-05 19:47
        回复
          请各位看看啊,真的是整了好久了


          来自手机贴吧8楼2017-09-05 19:49
          回复
            如上,请各位帮忙看看


            来自手机贴吧10楼2017-09-05 19:56
            回复


              来自手机贴吧11楼2017-09-05 19:57
              回复
                再顶


                来自手机贴吧12楼2017-09-05 20:04
                回复
                  再顶


                  来自手机贴吧13楼2017-09-05 20:04
                  回复