WilliamCode 2017-10-20 16:05 采纳率: 100%
浏览 1537
已采纳

新手java编程:在ArrayList中嵌套ArrayList,好像忘写了什么,数据丢失

写一个模拟选课系统,两个类:

第一个:单个学生信息

 public class Student {
    int ID;
    String name;
    List<Course> CourseSelected = new ArrayList<Course>();

    public Student(int num,String name) {
        this.ID=num;
        this.name=name;
    }

    public Student() {

    }

}

第二个:学生信息列表

 public class SCListGo {
    public static int NowPos = 0;
    List<Student> SCList = new ArrayList<Student>();
    }

看教程说在ArrayList中嵌套Set时候要重写HashSet,但是List我不知道。最后从第二个对象中提取Student对象时发现数据丢失了,用debug得到结果如下

图片说明
错误信息为:Detail formatter error:
Evaluations must contain either an expression or a block of well-formed statements
求大佬指教,怎么解

  • 写回答

2条回答 默认 最新

  • 羽異 2017-10-21 03:16
    关注

    你应该把代码都贴出来,基本没看明白你问的问题是什么

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

报告相同问题?