0

Syntax meaning in enhanced for loop (java)

I tried to solve this case but have no clues. int[] arr= {1,2,3,4,4}; for (x: arr) { arr[x]= 0; } // doest it mean that every values in arr will be replaced with 0? thanks.

15th Jul 2018, 3:11 AM
Paul Brugman
Paul Brugman - avatar
3 Respostas
0
yes
15th Jul 2018, 3:47 AM
Paul Grasser
Paul Grasser - avatar
0
Nah, if you print that array the result would be 0 0 3 0 0. This is where i got stuck.
17th Jul 2018, 4:01 AM
Paul Brugman
Paul Brugman - avatar
0
Oh, really? In other langs that means everything is 0.
17th Jul 2018, 5:34 AM
Paul Grasser
Paul Grasser - avatar