From 752aaa433bccca1f285d8f5d18bbc64b5a2794e8 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Mon, 9 Dec 2024 11:10:09 -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 ec23f6edf7..216c762027 100644 --- a/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java +++ b/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java @@ -430,9 +430,7 @@ public Object[] toArray() { public T[] toArray(final T[] arr) { // special implementation to handle disappearing keys final List list = new ArrayList<>(size()); - for (final K key : this) { - list.add(key); - } + forEach(list::add); return list.toArray(arr); } }