I have an Arraylist, for example
Arraylist
ArrayList newObjectList = new ArrayList<>();
I want to use an object from
You can disable the remove method using the Collections.unmodifiableList() construct:
remove
List newObjectList = Collections.unmodifiableList(new ArrayList());
This will throw an UnsupportedOperationException when trying to add or remove an object.
UnsupportedOperationException