+ 2
how to remove or update array? JAVA
If user input information in an array, how to remove or update them? This is pretty long code. https://code.sololearn.com/c5B61NSOUsn7 I don't even know how to start it... thank you for any help or comments!
1 ответ
+ 1
Search for the data: based on its name?email?
perform a loop and end the loop when it reaches the last data
when it finds the data, use the data's array number
for(int i=0; i<studentList.size(); i++){
student = (Student) studentList.get(i);
if ( student.getName().equalsIgnoreCase(searchedName){
//assign to the object here
found = true;
}
}
this is to update the data
if you want to remove the data be sure to decrement the array size after delete
I only remember completing tasks using data structure and I forgot about some java basics which is pretty bad