Inspectopedia Help

Redundant 'new' expression in constant array creation

Reports constant new array expressions that can be replaced with an array initializer. Array initializers can omit the type because it is already specified in the left side of the assignment.


int[] foo = new int[] {42};

After the quick-fix is applied:

int[] foo = {42};

Inspection Details

By default bundled with:

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin:

Java, 241.16690

Last modified: 29 April 2024