0
I can't figured out how this java code worked
public class Program { public static void main(String[] args) { int[] a = {1,2,3,4,1}; for(int n:a) a[n] = 0; for(int n:a) System.out.println(n); } } Output = 00301
9 Answers
+ 3
Musa Muhammad Ndagie
The loop is explained in the code below. Hope you understand it now.
https://code.sololearn.com/c0pij3z7g868/?ref=app
0
I understand it is an enhanced-for loop but I'm unable to figure out the logical steps it followed to get the output
0
Thank you, I'll try it out
0
OK thanksđ