In the project I'm working on, I have a 2D ArrayList that represents some data:
private ArrayList<ArrayList<T>> data = null;
Now I need to return this ArrayList to some object so that the object can check it, but does not modify it.
In the next article, I found that a 2D ArrayList needs to be wrapped in a separately non-modifiable wrapper, but it does not mention how to do this:
Is an unmodifiable wrapper for java collections thread safe?
So my problem is: how to return an immutable 2D ArrayList from an existing 2D ArrayList? And besides, what is the fastest way, since the data can be large in practice?
Thanks for all the inputs!
source
share