I have a method that returns an Immutable list. I want to add elements to it and that's why have to convert it to a mutable list. Currently, I am creating a new ArrayList out of the Immutable list as follows:
final List<someDTO> mutableList = new ArrayList<>(someDTO.getImmutableList());
Is there any better way of doing it like using some collections copy method, java streams, or anything like that?
in all honesty, that's as best as it gets, but another variant would be:
someDTO.getImmutableList().stream().collect(toCollection(ArrayList::new));