This is my first post and I would like to say that while lurking here for a while now, I am very impressed with the community and the support provided here. HUGE thanks to all that is making this possible. Also, thank you Kathy and Bert for all your books, interactive and interesting should be required whenever Comp Sci is the subject.
My question is from the K&B book page 344-345 #19
Question: which of the following code fragment inserted in "insert code here" will not compile?
Answer D & F Explanation F returns an primitive, not an object, D is a reference to a char primitive
Why not also C & E ?
Thanks for any responses.
( tags added) [ November 14, 2004: Message edited by: Barry Gaunt ]
posted 11 years ago
Hi, Arrays are actually Objects in Java. In fact, you can even do this:
The code above will make compiler happy. That's the case for C. As for E, here you have a multidimensional array (array of arrays). Hence, c is a reference to another array. Note that you can't return c, as this would return a primitive.
I would suggest to re-read a chapter on Java fundamentals (arrays), I'm sure K&B book has some decent info on this.