Created
September 25, 2016 21:07
-
-
Save oleglomako/588abcc6295bbb920966f81e65149b20 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.oleglomako.TrueRemoveFromArrayList; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.Iterator; | |
public class TrueRemoveFromArrayList { | |
public static void main(String[] args) { | |
ArrayList<String> list = new ArrayList<String>(Arrays.asList("a", "b", "c", "d")); | |
Iterator<String> iter = list.iterator(); | |
while (iter.hasNext()) { | |
String s = iter.next(); | |
if (s.equals("a")) { | |
iter.remove(); | |
} | |
} | |
System.out.println(list); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment