I want an ArrayList in Java that is unchangeable. So you can't delete or add any Elements. So all work is done by the Constructor.
So far I have tried making the List final the following way
public static final List<Integer> = new ArrayList<>;
This didnt work as you could somehow still add Elements to it.
Next I searched online and found out that you could override all Methods like this:
public NoChangeArrayList<T> extends ArrayList<T> {
@Override
public boolean remove() {
//do nothing...
}
//override all change methods
(...)
}
This though doesnt seem like a good solution to me, as I need to put in a lot of Work for such a simple thing.
Is there an easy way to make an unchangeable ArrayList?