Skip to content

array-type-style

Javastyleno fixdefault: offjava/google

Reports a variable or parameter that puts the array brackets after the name (int a[]).

In Java the brackets are part of the type, and int[] a says it at the start. The C form is allowed for compatibility and makes the type hard to read, and int[] a, b[] declares two different types in one line.

To fix, write the brackets after the type: int[] a.

Reported
class A {
int a[], b;
int[] c;
void f(String s[], String[] t, int... u) {
int d[] = new int[1];
}
}
java:
lint:
rules:
array-type-style: warn # off (default), warn, error

Enabled by the presets: java/google.

Suppress one line with sudsy-disable-next-line array-type-style in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
checkstyle ArrayTypeStyle full