Use forEach()

This commit is contained in:
Gary Gregory 2024-12-09 11:10:09 -05:00
parent de4b7f8bbe
commit 752aaa433b
1 changed files with 1 additions and 3 deletions

View File

@ -430,9 +430,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
public <T> T[] toArray(final T[] arr) {
// special implementation to handle disappearing keys
final List<K> list = new ArrayList<>(size());
for (final K key : this) {
list.add(key);
}
forEach(list::add);
return list.toArray(arr);
}
}