# help with multidimesional array qn

• 11-01-2011, 12:31 PM
luciawashaya
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]
• 11-01-2011, 01:30 PM
JosAH
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
• 11-01-2011, 02:09 PM
luciawashaya
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;
}
• 11-01-2011, 02:11 PM
luciawashaya
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[][];
}
• 11-01-2011, 02:22 PM
JosAH
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
• 11-01-2011, 03:23 PM
tnrh1
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.