Sandra Bachan wrote:
And the following five code fragments:
F1. if(f1 == f2)
F2. if(f1 == f2[2][1])
F3. if(x == f2[0][0])
F4. if(f1 == f2[1,1])
F5. if(f3 == f2[2])
I can understand that F2 and F3 compiles, and that F3 returns true. But why does F5 compile? Isn't f2 a 2-dimensional array?
And what does f2[2] even refer to? I would think the proper way to refer to an element in f2 would be f2[index 1][index 2].
Please clarify
The answer : F3,
And for compiling the option, you are comparing two, one dimensional arrays. Yea,
f2 is a two dimensional array. f2[2] refers a one dimensional array(
in your case, {2.6f, 2.7f}).
Sandra Bachan wrote:...would be f2[index 1][index 2]
This is for mat lab, not for
java. In java multi dimensional arrays are arrays of array.