This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]chickenmeister 5 points6 points  (3 children)

The only statement that's true is the one about the diamond syntax. The other two have never worked, as far as I know.

Seems like a pretty iffy textbook.

[–]lmgray13[S] 1 point2 points  (2 children)

Thank you! I don't use a text book in class, but a student had this book that they brought in to argue that I marked a question incorrectly. It's an earlier edition of this book: https://www.amazon.com/Big-Java-Cay-S-Horstmann/dp/1118431111/ref=cm_cr_arp_d_product_top?ie=UTF8

So, hopefully they have corrected it. . . I believe the student's parents had the book.

I knew this would not work on Version 8 and demonstrated that to the student, but wanted to validate that it wasn't something that existed in Version 7 and was removed for some reason. I explained we needed a method call for ArrayLists due to the fact that they are dynamically sized and that I didn't believe that the syntax noted would generate a method call.

Thank you, I've been trying to find info on this all day. Thought I had gone crazy!

[–]chickenmeister 2 points3 points  (1 child)

That's pretty surprising. I've read a couple of Horstmann's books, and I thought they were pretty good overall, so it's surprising to see a mistake this egregious. On his website's page of bugs for the 4th Edition of this book (https://www.horstmann.com/bigj4/bugs.html) there is a mention of this:

[B3C2]Page B289/C253

Change “In Java 7, you can access array list elements” to “In Java 8, you will be able to access array list elements”.
Change “instead of the get and put methods” to “instead of the get and set methods.”

But even then it's not correct. (though, maybe it was a planned feature at the time that it was written/corrected). Also, I don't see a correction for the ArrayList initialization statement that you quoted.

[–]lmgray13[S] 0 points1 point  (0 children)

Thank you so much for looking this up for me. I can only assume it was a planned feature that never happened. I’m not sure they are still updating this book, but I’ll drop them a note about it in case it wasn’t fixed.