java arrays

View: New views
1 Messages — Rating Filter:   Alert me  

java arrays

by asp2801 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

i have two arrays which will take numbers and no. of rows and columns fron method getArr()
ifter that i want to ensure when no. of rows of first array = no. of rows of second matrix

(and columns also) further code should be executed.
code is:

int a[][] = getArr();
int b[][] = getArr();
int a1,a2,a3,a4;
a1 = a.length; a2 = b.length;
a3 = a[a1].length; a4 = b[a2].length;
if(  (a1!=a2) || (a3!=a4) )
        {
        System.out.println ("Error in dimensions");
        }

I'm getting ArrayOutOfBound exception
is any wrong with above code ?