I need to make a copy of HashMap > but when I change something in the copy I want the original to stay the same. i.e w
HashMap >
This does need iteration unfortunately. But it's pretty trivial with Java 8 streams:
mapCopy = map.entrySet().stream() .collect(Collectors.toMap(e -> e.getKey(), e -> List.copyOf(e.getValue())))