I am beginner in java i want to take input of an multidimensional array from user using for loop.
i have tried the following code but its giving some thread error.
Scanner input = new Scanner(System.in);
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
a[i][j] = input.nextInt();
//System.out.println(a[i][j]);
}
}
}
Scanner input = new Scanner(System.in);
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
int a[i][j] = input.nextInt();
}
}
}
Exception in thread "main" java.lang.NullPointerException at practice.prac.main(prac.java:16)