what is the output of this code? array list<Integer>list=new Array list<Integer>(); for(into 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); | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

what is the output of this code? array list<Integer>list=new Array list<Integer>(); for(into 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);

26th Mar 2017, 11:42 AM
Teja Swini
Teja Swini - avatar
2 Answers
+ 7
0 + 1 + 2 + 3 + 4 + 5 = 15
26th Mar 2017, 11:43 AM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
- 4
06
26th Mar 2017, 11:43 AM
Teja Swini
Teja Swini - avatar