I have a very basic question. 

I have created simple ArrayList and I am removing the item while iterating using for-each loop. It gives me java.util.ConcurrentModificationException because I can't remove an item while iterating but when I un-comment the if condition it works fine. 

Please can anybody explain me how for-each works in this way.      

    ArrayList&lt;String&gt; list1 = new ArrayList&lt;String&gt;();
    list1.add("Hello");
    list1.add("World");
    list1.add("Good Evening");

    for (String s : list1) {
        //if (s.equals("World")) {
            list1.remove(1);
        //}
    }


If I change it to list1.remove(2); or list1.remove(0); then also its working fine. 

Note: This is sample code and I know it will work fine using Iterator. My sole purpose of this question is to know how method remove() works perfectly if condition is un-commented no matter what index you are removing from the list.


Question: Flash Memory Failure Modes - Block Failure
Answer: Depending upon how error-correcting codes are implemented, it may be possible for a chip to detect a larger number of bad bits than it can reliably correct.  If a chip detects the existence of uncorrectable errors, having it return all-zero data may be safer than having it try to correct the data, especially if software tries to add its own error-correcting logic.  Personally, I think the "right" approach would be to have a standard means via which a chip could give an indication of data reliability (block is "clean", block has correctable errors but can tolerate more, block is near the limit for correctable errors, block has unrecoverable errors, etc.) but in the absence of such a feature I wouldn't think it unusual for blocks to transition rather abruptly between working perfectly and being totally useless.