ArrayList<Integer> list = new ArrayList<>();
int sum = 0;
for (int x : list) sum += x;
System.out.println(sum + " " + list.size());What is printed?
- A
Runtime error
- B
0 1
- C
1 0
- Dcheck_circle
0 0
Explanation
The list is empty so the for-each loop never executes, sum stays 0, and size is 0.