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 216c76202..46f713509 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 abstract class AbstractReferenceMap extends AbstractHashedMap 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); } }