Can anyone tell me why j gets the value of y, instead of 0 in the following snippet?
Code:
import java.util.Scanner; public class matrix { public int x,y; public void init(int[][] matrix1) { int i; int j; Scanner input = new Scanner(System.in); System.out.printf("Enter x:"); x=input.nextInt(); System.out.printf("Enter y:"); y=input.nextInt(); matrix1 = new int[x][y]; for( i=0 ; i<x ; i++) { for( j=0 ; j<y ; j++); { //System.out.println("enter:"); System.out.printf("%d %d",i,j); matrix1[i][j]=0; } } } }
Comment