# Thread: help with multidimesional array qn

1. Member
Join Date
Oct 2011
Posts
11
Rep Power
0

## help with multidimesional array qn

b) Given two equal sized double arrays : X, Y initialized with some non sorted numbers, and a third equal sized boolean array Z . Write a Java method to check the equality of corresponding elements of array X and Y elements , and put the result into the corresponding index element of boolean array Z . [10 marks]

2. ## Re: help with multidimesional array qn

So, Z[j]= X[j] == Y[j]? If so, put a loop around it and pass me the 10 marks.

Jos

3. Member
Join Date
Oct 2011
Posts
11
Rep Power
0

## Re: help with multidimesional array qn

public boolean findMacthes([][]x,[][]y){
if([][]x!=[][]y){

return null;
}
for(int a = 0;a<x.length;a++){
for(int c = 0 ;c<y.length;c++){
result [a][c] = true;
}
}
}
return result;
}

4. Member
Join Date
Oct 2011
Posts
11
Rep Power
0

## Re: help with multidimesional array qn

public boolean findMacthes([][]x,[][]y){
if([][]x!=[][]y){

return null;
}
boolean [][]Z=new boolean [x.length,y.length]
for(int a = 0;a<x.length;a++){
for(int c = 0 ;c<y.length;c++){
Z[a][c] = true;
}
}
}
return z[][];
}

5. ## Re: help with multidimesional array qn

Did your compiler like it? I guess not; don't just guess what the Java language should be in your imagination; read a textbook.

kind regards,

Jos

6. Senior Member
Join Date
Aug 2011
Posts
251
Rep Power
6

## Re: help with multidimesional array qn

Check if x[index] == y[index], if true z[index] = true else z[index] false.
You don't need a nested loop, and as JosAH said, read a textbook it's not looks like Java.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•