Prefer enhanced for loops instead of explicitly using an iterator where possible.
That is, prefer this:
for (T element : list) {
doSomething(element);
}
to this:
for (Iterator<T> iterator = list.iterator(); iterator.hasNext(); ) {
doSomething(iterator.next());
}
Suppress false positives by adding the suppression annotation @SuppressWarnings("ForEachIterable")
to the enclosing element.