Imagine that I have this class:
public class Test { private String[] arr = new String[]{\"1\",\"2\"}; public String[] getArr() { return arr;
If you can use a List instead of an array, Collections provides an unmodifiable list:
public List getList() { return Collections.unmodifiableList(list); }