23 lines
442 B
Plaintext
23 lines
442 B
Plaintext
|
import java.util.ArrayList;
|
||
|
import java.lang.Integer;
|
||
|
import java.lang.Number;
|
||
|
|
||
|
public class ForEach {
|
||
|
public m() {
|
||
|
var list = new ArrayList<>();
|
||
|
list.add(1); list.add(2); list.add(3);
|
||
|
|
||
|
var sum = 0;
|
||
|
for (var i : list) {
|
||
|
sum = sum + i;
|
||
|
}
|
||
|
return sum;
|
||
|
}
|
||
|
|
||
|
public m2() {
|
||
|
var list = new ArrayList<? extends Number>();
|
||
|
|
||
|
for (Number n : list) {
|
||
|
}
|
||
|
}
|
||
|
}
|