0

What is the output and how?

int []a = {1,2,3,4,1}; for(int n : a) a[n] = 0; for(int n : a) System.out.println(n);

30th Aug 2022, 8:15 AM
Rohit Ahuja
Rohit Ahuja - avatar
2 odpowiedzi
+ 4
The output is 00301 : - 1st element is 1 : a[1] = 0 => 10341 - 2nd element is now 0 : a[0] = 0 => 00341 - 3rd element is 3 : a[3] = 0 => 00301 - 4th element is now 0 : a[0] = 0 => 00301 - 5th element is 1 : a[1] = 0 => 00301
30th Aug 2022, 11:09 AM
Roland
Roland - avatar
+ 1
Thnx
30th Aug 2022, 5:26 PM
Rohit Ahuja
Rohit Ahuja - avatar