Back to Intellij Community

ArrayCanBeReplacedWithEnumValues

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

2025.3-rc-2471 B
Original Source

Reports arrays of enum constants that can be replaced with a call to EnumType.values().

Usually, when updating such an enum, you have to update the array as well. However, if you use EnumType.values() instead, no modifications are required.

Example:

enum States {
     NOT_RUN, IN_PROGRESS, FINISHED;
  }

  handleStates(new States[] {NOT_RUN, IN_PROGRESS, FINISHED});

After the quick-fix is applied:

handleStates(States.values());

New in 2019.1