android - For Loop on ArrayList Exception -
I apologize for the limited title, but I do not know how to describe this problem I have a loop Which repeats through an array list with an array. One object management is a boolean that is set at a different point in time. The point of the loop is to go through the array list and remove each item as incorrect as a boolean.
if (! ArrayList.isEmpty ()) {int len = arrayList.size}; (Int i = 0; i & lt; len; i ++) for {if array! }}} For loop always leaves more than one object in the array. This is because because of the items removed in the array for loop cycles every time the LAN drops down and can cancel the loop before removing the object on the last object. I understand this problem, but I do not know how to fix it I have tried to do something like LAN + 1, but when I do something for it, this one index throws an output bond exception. any idea? Besides, is the best way to do what I am trying to do?
That you do not use methods that come after items you extracted.
for (int i = arrayList.size () - 1; i> = 0; i--) {} alternative form From, you can reduce the i to use the next code, and get rid of the len variable so that the end position uses the actual length.
Comments
Post a Comment