4

Is there any other option for me to modify an unmodifiable list apart from manual traversal and putting content into new array?

Some developers choose to build APIs this way rather than cloning ..

Tian Na
  • 846
  • 2
  • 15
  • 30
  • Your question is quite self contradicting... If it's an _unmodifiable_ list then it can't be _modified_ by any means... So you're going to have to clone it. – px06 Aug 31 '16 at 10:06

1 Answers1

4

Many collections accepts another Collection as a constructor argument. You can do something like:

List<T> mutable = new ArrayList<>(immutable);

And then just deal with mutable collection.

vsminkov
  • 10,912
  • 2
  • 38
  • 50