+ 1
Anyone can explain how dose it work briefly.
public class Program { public static void main(String[] args) { int[] a = {1,2,3,4,1}; for(int n:a) { a[n] = 0; System.out.println(n); } } } O/p: 1 0 3 0 1
3 Antworten
+ 2
It's changing the elements of the array:
a[1] = 0
Outputs n -> 1
a[2] = 0
Outputs n -> 0 ( set in the previous step)
a[3] = 0
Outputs n -> 3
a[4] = 0
Outputs n -> 0 ( set in the previous step)
a[1] = 0
Outputs n -> 1.
+ 1
Krishnanshu Dey , you are welcome 😉
0
Yaa I got it thanks