25 lines
760 B
Plaintext
25 lines
760 B
Plaintext
The array brackets (``++[]++``) for methods that return arrays may appear either immediately after the array type or after the list of parameters. Both styles will compile, but placing array brackets at the end of the method signature is deprecated, and retained in the language specification only for backward compatibility.
|
|
|
|
|
|
Additionally, placing the array brackets at the end is far less readable than keeping the brackets with the return type. Therefore, this style should be found only in legacy code, never in new code.
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
----
|
|
String sayHello() [] { // Noncompliant
|
|
return new String[] {"hello", "world"};
|
|
}
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
String [] sayHello() {
|
|
return new String[] {"hello", "world"};
|
|
}
|
|
----
|
|
|
|
|