arraylist - Java save function won't overwrite -
I created an object that I then added to an arraylist. I then saved this array in a .dat file using the orroutputstream. I know that the object is created correctly because the program loads directly from the next screen object and the object can be read properly from the file later. The issue I am running is that it seems that the object is saving, but it is not ready to edit. Rather than editing the object in the array list, it is creating a new object and saving it every time.
The code below shows the save function which eliminates the last screen every time. I am trying to make it so that it can see if the student is already in the array and if so, then edit the object if the student is not present, then I selected it (used for all GUI functions) Object) and add it to the "students" array and write the array in the file, overwriting all the previous data.
Edit: I have seen that the variable is present which is the fault number one, but was not being used to search, but I still have a problem Where the saved item will not be changed unless the method is not called for a second time it seems that it is being played again, but when it is played for the first time, it just becomes a new student with the edited name Will give For example, the first student was created and saved. The second student is created and saved when another student is being edited (without closing the program and restarting the program), instead of editing the object in the file, create a new student object with the same information directly from the first directly below The editing function is run for the second time, the second student file is edited properly, but for the first time it leaves it.
I will edit these lines for a start
if (Students.get (i) .getID (.) Equals (selectedStudent.getID ())) {exist = i; } {System.out Println}
to if (students.get (i) .getID (.) Equals (selectedStudent.getID ())) {System.out ("Understand it"); Exists = i; break; }
Just to make sure that it is working.
In addition, you i
to exists
other {students.set (i, selected student); // change in existence}
Comments
Post a Comment