List<Employee> unique=employees.stream()
.collect(Collectors.collectingAndThen(Collectors.toCollection(()->
new TreeSet<>Comparator.comparing(Employee::getIdentifier))),
ArrayList::new));
unique.stream()
.forEach(employee->employee.setQuantity(0L));
此处更改unique
中的值也会更改employees
中的值。如何解决?