Every time I try to call ArrayList.remove() on an element while in a for each loop, Java throws a ConcurrentModificationException. I need to remove an element in a for loop because in there is where I look through the objects to find objects which meet the criteria for removal.
ENTERPRISE COMMENTING BY JOHN BLOCH AND NEAL FAGTER
93 * @author Josh Bloch
94 * @author Neal Gafter
884 /**
885 * Returns a view of the portion of this list between the specified
886 * {@code fromIndex}, inclusive, and {@code toIndex}, exclusive. (If
887 * {@code fromIndex} and {@code toIndex} are equal, the returned list is
888 * empty.) The returned list is backed by this list, so non-structural
889 * changes in the returned list are reflected in this list, and vice-versa.
890 * The returned list supports all of the optional list operations.
891 *
892 * <p>This method eliminates the need for explicit range operations (of
893 * the sort that commonly exist for arrays). Any operation that expects
894 * a list can be used as a range operation by passing a subList view
895 * instead of a whole list. For example, the following idiom
896 * removes a range of elements from a list:
897 * <pre>
898 * list.subList(from, to).clear();
899 * </pre>
900 * Similar idioms may be constructed for {@link #indexOf(Object)} and
901 * {@link #lastIndexOf(Object)}, and all of the algorithms in the
902 * {@link Collections} class can be applied to a subList.
903 *
904 * <p>The semantics of the list returned by this method become undefined if
905 * the backing list (i.e., this list) is <i>structurally modified</i> in
906 * any way other than via the returned list. (Structural modifications are
907 * those that change the size of this list, or otherwise perturb it in such
908 * a fashion that iterations in progress may yield incorrect results.)
909 *
910 * @throws IndexOutOfBoundsException {@inheritDoc}
911 * @throws IllegalArgumentException {@inheritDoc}
912 */
913 public List<E> subList(int fromIndex, int toIndex) {
914 subListRangeCheck(fromIndex, toIndex, size);
915 return new SubList(this, 0, fromIndex, toIndex);
916 }
>>37 Also, an array in C *cannot* be expanded using realloc(). Holy cripes, please shut up and read a book.
I think you took his statement more literal then it was meant to be taken. You have a bad day at work like you seem to always do? Enterprise java getting you your head after all these years ?
There's another thing, you need to realize there's more than 2 people on this board ( you and me ). I'm not the one that originally wrote that post but i at least clearly understand what he was getting. Please do not accuse me of such horrible travesties.
Now, lets talk about your anger issues you appear to be having. Take the next 10 minutes to write down a list of all the things that anger you in the world and post it to share with the group. We're here to help you.
Name:
Anonymous2012-01-18 20:28
>>48
1)Ex girlfriends who posts pictures of me "being her bitch" on myspace.
2)The neighbors dog. I swear if I hear that thing bark one more time at 3am, I'm gonna throw an m80 over the fence, and then call 911 to report that I heard a gunshot next door.
>>53
I guess it would have been smarter of me to actually look at his job title for all those jobs
Name:
Anonymous2012-01-18 20:54
>>51
Now all we have to do is contact him and see if he remembers any man that would ramble on about mental midget toilet scrubbers and we'll find out who you truly are.
error checking is bloat when errors should never happen, and errors should never happen, but sometimes they do, and if there is checking, then you are less fucked than if errors were checked, but you are stilled fucked, but the fucking up only prevents the functioning of your program, rather than causing it to do something completely arbitrary, or intentional from a hacker who has learned how to exploit the error, so sometimes it is worth it to have the error checking, but if the application is proved correct and if speed is needed, then error checking can get in teh way of getting adequate speed.