I am working with classes and arrayLists, i want to update an element(object) in the ArrayList. fist i searched for it, by the ID number. then I reseted the object members using a method in the class that prompt user for input..
the problem is, it update all the objects in the list not one in particular.
my work
if (studentList.isEmpty())
System.out.println("\t\tNO DATA TO UPDATE !!");
else {
try {
System.out
.print("\n\tTo Update info, Please Enter Students ID: ");
System.out.flush();
searchID = obj.readLine();
for (Iterator<Student> it = studentList.iterator(); it
.hasNext();) {
Student S1 = it.next();
if (searchID.equals(S1.getID()))
System.out.print("\n\tEnter New Data: ");
S1.setting();
}
} catch (Exception e) {
// empty
}
}
it asks to update all the objects instead of one. the update works but not the way i want...