Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Lists - removing with iterator

List<String> names = new ArrayList<>(List.of("John Doe", "Jack Doe", "John Smith"));
Iterator<String> it = names.iterator();
while (it.hasNext()) {
    String name = it.next();
    if (name.startsWith("John")) {
        it.remove();
    }
}
Source by github.com #
 
PREVIOUS NEXT
Tagged: #Lists #removing #iterator
ADD COMMENT
Topic
Name
6+8 =