Imagine that I have this class:
public class Test { private String[] arr = new String[]{\"1\",\"2\"}; public String[] getArr() { return arr;
You must return a copy of your array.
public String[] getArr() { return arr == null ? null : Arrays.copyOf(arr, arr.length); }