Files
openide/java/java-tests/testData/inspection/java8CollectionRemoveIf/beforeIteratorRemoveWhile.java
Louis Vignier 170c838207 [java] Update inspection descriptions
GitOrigin-RevId: 1c55fac4ca08678e76aee02962ddf12153dd51cd
2021-03-16 14:56:20 +00:00

17 lines
476 B
Java

// "Replace the loop with 'Collection.removeIf'" "true"
import java.util.*;
public class Main {
public void removeEmpty(List<String> list) throws Exception {
Iterator<String> it = list.iterator();
while<caret>(it.hasNext()) {
String str = it.next();
// remove empty
if(str.trim()/*trimmed empty*/
.isEmpty()) {
it.remove();
}
// everything is ok!
}
}
}