Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Edited by NavBot

...

Code Block
bgColor#FFcccc
class BadIterate {
  public static void main(String[] args) {
  List&lt;String&gt;List<String> list = new ArrayList&lt;String&gt;ArrayList<String>();
  list.add(&quot;one&quot;"one");
  list.add(&quot;two&quot;"two");
        
  Iterator iter = list.iterator();
  while(iter.hasNext()) {
    String s = (String)iter.next();
    if(s.equals(&quot;one&quot;"one"))
      list.remove(s);
    }
  }    
}

Compliant Solution

...

MSC32-J. Make sensitive classes noncloneable&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      49. Miscellaneous (MSC)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;99. The Void (VOID)      MSC34-J. Do not base critical decisions on IP addresses or DNS lookups