0
What is the output of this code?
ArrayList<Integer> list = new ArrayList<Integer>(); for (int i = 0; i < 6; i++) { list.add(i); } int x = 0; Iterator<Integer> it = list.iterator(); while (it.hasNext()) { x+= it.next(); } System.out.println(x);
6 odpowiedzi
+ 11
It's the sum of numbers from 0 to 5 = 15
+ 6
Code Playground has the answer.
0
15
0
15
0
15
0
15