日期:2014-05-20  浏览次数:20647 次

在Eclipse下编译直接通不过,可是直接在命令行下是可以运行的,求解。。。
class Person{
private String id;
public Person(String id){
this.id=id;
}
public String getId(){
return id;
}
public String toString(){
return id+"";
}
}

class Student extends Person{
private String stuId;
public Student(String id,String stuId){
super(id);
this.stuId=stuId;
}
public String getStuId(){
return stuId;
}
public String toString(){
return this.getId()+":"+stuId+" ";
}
}

class PersonManage{
public Person[] infoList;
public PersonManage(){
infoList=new Person[3];
infoList[0]=new Person("111");
infoList[1]=new Person("222");
infoList[2]=new Person("333");
for(int i=0;i<infoList.length;i++){
System.out.println(infoList[i]);
}
}
public Person getOne(int index){
if(index>=0 && index<infoList.length){
return infoList[index];
}
else{
return null;
}
}
public String toString(){
return infoList[0].toString()+infoList[1].toString()+infoList[2].toString();
}
}

class StudentManage extends PersonManage{
public Student[] infoList;
public StudentManage(){
infoList=new Student[3];
infoList[0]=new Student("111","999");
infoList[1]=new Student("222","888");
infoList[2]=new Student("333","777");
for(int i=0;i<infoList.length;i++){
System.out.println(infoList[i]);
}
}
public Student getOne(int index){
if(index>=0 && index<infoList.length){
return infoList[index];
}
else{
return null;
}
}
public String toString(){
return infoList[0].toString()+infoList[1].toString()+infoList[2].toString();
}
}
public class TestStudentManage {

/**
* @param args
*/
public static void main(String[] args) {
System.out.println("第一个调用!");
StudentManage stuMge=new StudentManage();
Student stu=stuMge.getOne(1);
System.out.println(stu.getId());
System.out.println(stu.getStuId());
System.out.println("用来与第二个调用对比的输出如下:");
System.out.println(stuMge.infoList[0]);
System.out.println("第二个调用!");
PersonManage personMge=new StudentManage();
System.out.println(personMge.infoList[0]);

}

}

------解决方案--------------------
编译通不过有报什么错没有,有什么提示没有,可能是你的版本问题引起的。
------解决方案--------------------
eclipse下,要新建TestStudentManage.java文件,而且不能放在包里。。
------解决方案--------------------
你怎么个报错法
------解决方案--------------------
Java code

为什么我的eclipse能通过?