we cannot modify a list while iterating it. what if it is required to modify that how can i do that in java | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

we cannot modify a list while iterating it. what if it is required to modify that how can i do that in java

i m making a program to sort an array.by program will run through every number and check if it is the biggest number and then remove that so i need to modify it while iterating.

13th Jun 2017, 8:23 AM
shobhit
shobhit - avatar
2 Answers
+ 2
can't you just sort it and then remove the highest number? you would then repeat the process.
13th Jun 2017, 12:45 PM
Daemo
Daemo - avatar
+ 1
well what if we don't want to use any existing class.
13th Jun 2017, 4:25 PM
shobhit
shobhit - avatar