Page 1 of 1

About Question enthuware.ocpjp.i.v11.2.3237 :

Posted: Sat Feb 15, 2020 9:00 am
by Deleted User 6318
I have a question about the explanation of 5th array declaration:

Code: Select all

char[][] cA = {"1234", "1234", "1234"};
Option 5 creates a one dimensional array and that too of Strings. Note that a java String is not equivalent to a one dimensional array of chars.

I agree that the right side of equals operand does it, but it does not match declaration, so such a line won't even compile. I think it's worth noting.

Re: About Question enthuware.ocpjp.i.v11.2.3237 :

Posted: Sat Feb 15, 2020 9:15 am
by admin
Correct. And as the second line of the explanation notes, "a java String is not equivalent to a one dimensional array of chars.", therefore the right hand side is not equivalent to a two dimensional array of chars. And so the line won't compile.

The explanation has now been enhanced to make this clear.

thank you for your feedback!