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]
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
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;
}
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[][];
}
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
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.