If you absolutely must do this, try to follow the contract specified by java.util.List in the list you are creating.
Your code would look something like
public class UnmodifiableArrayList<E> extends ArrayList<E> {
public UnmodifiableArrayList(Collection<? extends E> c) {
super(c);
}
public boolean add(int index) {
return false;//Returning false as the element cannot be added
}
public boolean addAll(Collection<? extends E> c) {
return false;//Returning false as the element cannot be added
}
public E remove(int index) {
return null;//Returning null as the element cannot be removed
}
}
Add any more methods you need on the same lines. Just ensure that all the constructors and methods that might by used to modify in your code are overriden, so as to ensure the list is unmodifiable.
Using the Collections API is the cleaner and better way to do it, so use this way only if using Collections.UnmodifiableList does not satisfy your need.
And keep in mind this will be a nightmare while debugging so log as much as possible.