mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8274715: Implement forEach in Collections.CopiesList
Reviewed-by: martin
This commit is contained in:
parent
d4e8712c0a
commit
df7b0c7077
2 changed files with 44 additions and 0 deletions
|
@ -5182,6 +5182,16 @@ public class Collections {
|
|||
return element;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEach(Consumer<? super E> action) {
|
||||
Objects.requireNonNull(action);
|
||||
int n = this.n;
|
||||
E element = this.element;
|
||||
for (int i = 0; i < n; i++) {
|
||||
action.accept(element);
|
||||
}
|
||||
}
|
||||
|
||||
public Object[] toArray() {
|
||||
final Object[] a = new Object[n];
|
||||
if (element != null)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue