Back to Intellij Community

SequencedCollectionMethodCanBeUsed

java/java-impl/resources/inspectionDescriptions/SequencedCollectionMethodCanBeUsed.html

2025.3-rc-2464 B
Original Source

Reports collection API method calls that can be simplified using SequencedCollection methods.

The following conversions are supported:

  • list.add(0, element)list.addFirst(element);
  • list.get(0)list.getFirst();
  • list.get(list.size() - 1)list.getLast();
  • list.remove(0)list.removeFirst();
  • list.remove(list.size() - 1)list.removeLast();
  • collection.iterator().next()collection.getFirst();

New in 2023.3