I am new to Java and i am using eclipse for its compilation. I have seen many forums but i am not able to get around this error. I am creating a program for my homework and this is a small section of that program which is giving weird error. Any help is appreciated.
Here is where i am getting error -> aTwoD[i][j] = 0; <- at Initialize2D.<init>(Initialize2D.java:19)
I am stuck on this for quite some time now. :-(
What is did ->
public class Initialize2D
{
private int[][] aTwoD;
public Initialize2D (int N)
{
System.out.println("N = " +N);
int counter = 0;
aTwoD = new int[N][N];
int i = 1;
while( i <= N )
{
int j = 1;
while( j <= N )
{
System.out.println("counter = " +counter);
aTwoD[i][j] = 0;
System.out.println("aTwoD["+i+"]["+j+"] = " + aTwoD[i][j]);
j++;
counter++;
}
i++;
}
}
public static void main( String[] args)
{
Initialize2D TwoDArray = new Initialize2D(2);
}
}