this code gives [0,o,3,0]as answer can any body explains the reason
import java.util.*; class test { public static void main( String args[] ) { int []arr = {1,2,3,4}; for ( int i : arr ) { arr[i] = 0; } System.out.println(Arrays.toString(arr));
This question has been asked too many times. Search it to find a solution. I think it's time to put it in the FAQ. Here's a bit of searching that I did