From 84cfe34d807f3b51d9b491e7d0f06411506935c9 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Mon, 9 Dec 2024 12:25:03 -0500 Subject: [PATCH] Use forEach() --- .../apache/commons/collections4/map/AbstractReferenceMap.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java b/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java index 216c762027..46f713509f 100644 --- a/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java +++ b/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java @@ -559,9 +559,7 @@ public Object[] toArray() { public T[] toArray(final T[] arr) { // special implementation to handle disappearing values final List list = new ArrayList<>(size()); - for (final V value : this) { - list.add(value); - } + forEach(list::add); return list.toArray(arr); } }