문제

I'm reading in a set of data from serializable and as a result I get 2 sets of data, the old one that was already there and the new one that I've just loaded in. I managed to create a separate set of data and it kind of works but it's not the ideal solution here. I'm loading stuff into ArrayLists but that just seems to make the entries null rather than deleting them. So I was wondering how do I overwrite with serializable? Here is my current code that I use to load in the data:

//students.clear();
//modules.clear();      
    Model m = new Model();
    m=Model.readModule("out.ser");
    m.findStudent();

Like I said this created a new instance of Model, but I would rather have it replace the current instance but I'm unsure on how to do that.

도움이 되었습니까?

해결책

If you have students and modules array lists then you can do:

students.clear();
modules.clear();

Model m = Model.readModule("out.ser");

students.addAll(m.getStudentsList());
modules.addAll(m.getModulesList());

Hope this helps.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top