Look at your code:
int A[][]=new int[4][];
for(I=0;I<4;I++){
for(j=0;j<5;j++){
A[I][j]= k;
k++;
}}
And let's start by making it a little more readable, shall we?
int a[][] = new int[4][];
for(i = 0; i < 4; i++){
for(j = 0; j < 5; j++){
a[i][j] = k;
k++;
}
}
Be consistent in your variable naming: local variables should be lowercase, not a mixture, and
get your indentation correct! It makes your code a whole load easier to read...
You declare the 2D array, but you only specify one size: so the system doesn't allocate any memory for the "second dimension". No memory, and it will fail when you try to access it.
Try this:
int a[][] = new int[4][5];
It should get you a little further.