报告可以折叠为单个 Collection.removeIf 调用的循环。

示例:


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

在应用快速修复后:


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

仅当项目或模块的语言级别为 8 或更高时才报告此检查。

2016.3 的新功能