diff --git a/patterns-modules/data-oriented-programming/src/main/java/com/baeldung/patterns/data/Roll.java b/patterns-modules/data-oriented-programming/src/main/java/com/baeldung/patterns/data/Roll.java index 18fe0920da37..541355e1fd2b 100644 --- a/patterns-modules/data-oriented-programming/src/main/java/com/baeldung/patterns/data/Roll.java +++ b/patterns-modules/data-oriented-programming/src/main/java/com/baeldung/patterns/data/Roll.java @@ -9,7 +9,6 @@ public record Roll(List dice, int rollCount) { throw new IllegalArgumentException("A Roll needs to have exactly 5 dice."); if (dice.stream().anyMatch(die -> die < 1 || die > 6)) throw new IllegalArgumentException("Dice values should be between 1 and 6."); - - dice = Collections.unmodifiableList(dice); + dice = List.copyOf(dice); } }