...
Code Block | ||
---|---|---|
| ||
public static final String[] items = { ... }; |
Compliant Solution (clone the array)
This compliant solution defines a private
array and a public
method that returns a copy of the array.
Code Block | ||
---|---|---|
| ||
private static final String[] items = { ... };
public static final String[] somethings() {
return items.clone();
}
|
...
Code Block | ||
---|---|---|
| ||
private static final String[] items = { ... };
public static final List<String> itemsList =
Collections.unmodifiableList(Arrays.asList(items));
|
...