단일 Collection.removeIf() 호출로 축소 가능한 루프를 보고합니다.

예:


  for (Iterator<String> it = collection.iterator(); it.hasNext(); ) {
    String aValue = it.next();
    if(shouldBeRemoved(aValue)) {
      it.remove();
    }
  }

빠른 수정을 적용한 후:


  collection.removeIf(aValue -> shouldBeRemoved(aValue));