
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
41 lines
1023 B
Plaintext
41 lines
1023 B
Plaintext
== Why is this an issue?
|
|
|
|
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
|
|
|
|
[source,java]
|
|
----
|
|
String sayHello() [] { // Noncompliant
|
|
return new String[] {"hello", "world"};
|
|
}
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,java]
|
|
----
|
|
String [] sayHello() {
|
|
return new String[] {"hello", "world"};
|
|
}
|
|
----
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Move these array brackets to just after the return type
|
|
|
|
|
|
endif::env-github,rspecator-view[]
|