Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ffcccc
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
bgColor#ccccff
private static final String[] items = { ... };

public static final String[] somethings() {
  return items.clone();
}

...

Code Block
bgColor#ccccff
private static final String[] items = { ... };

public static final List<String> itemsList =
Collections.unmodifiableList(Arrays.asList(items));

...