How arr comes after x : | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

How arr comes after x :

3rd Mar 2017, 6:34 AM
r vijayan
r vijayan - avatar
5 Answers
+ 8
Please post code.
3rd Mar 2017, 6:50 AM
Tashi N
Tashi N - avatar
+ 8
@r This is a for each loop. Iterates through the whole array. You need to init the array before looping through it.
3rd Mar 2017, 11:35 AM
Tashi N
Tashi N - avatar
0
int total =0; for(int x : arr){ total += x; }
3rd Mar 2017, 6:56 AM
r vijayan
r vijayan - avatar
0
enhanced for loop
3rd Mar 2017, 8:14 AM
Twelfty
Twelfty - avatar
0
total question should be like below: int[] arr={2,3,5,7}; int total=0; for (int x: arr) { total +=x; } but they have removed the first line. Hope now you understood this
15th Jul 2017, 8:19 AM
srikanth cherukupalli
srikanth cherukupalli - avatar