This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

OCPJP8 errata addition, page 213  RSS feed

 
Greenhorn
Posts: 7
2
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the middle of page 213, the book asks which functional interface would we fill in the blank with to make the code compile. It concludes:

"The only functional interface meeting all three of those criteria is DoubleToIntFunction"

However, that is not the only functional interface that would allow the code to compile. You can also use ToIntFunction<Double> or ToIntFunction<Object>, and the code above will compile.
 
Peter Deak
Greenhorn
Posts: 7
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, on the middle of page 306 there appears to be a word missing in the sentence:

"They made it legal to write Exception in the catch block but really only a limited set of exceptions"

I guess it's meant to be something like:

"They made it legal to write Exception in the catch block but really only mean a limited set of exceptions"
 
Peter Deak
Greenhorn
Posts: 7
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, at the bottom of page 458, it claims that the following code throws an exception:



This doesn't appear to be the case on Windows. When I run this code on java version "1.8.0_74":



I get the output below, with no exception:

 
Peter Deak
Greenhorn
Posts: 7
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, on page 573, answer to question 20. The answer and explanation are correct, but the code would fail to compile even before the reasons given; it contains a try-with-resources statement with no { } block. Instead it has an invalid try { .... }; form.
 
Peter Deak
Greenhorn
Posts: 7
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, on page 563, question 10 explanation.

The answer C is correct, but based on the three argument overload for reduce, it is c1 that would be an int and c2 would be the String. The explanation claims the opposite (that c1 is the String and c2 is the int).
 
author & internet detective
Posts: 39129
723
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
page 213 - You’re right! Have a cow for that really good catch. I wasn’t thinking about autoboxing! Have a cow for that great find!
page 306 - agreed
page 458 - confirmed
page 563 - confirmed
page 573 - yuck. I missed this in a number of places. (Because I create questions by copy/pasting code.)
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Peter Deak wrote:In the middle of page 213, the book asks which functional interface would we fill in the blank with to make the code compile. It concludes:

"The only functional interface meeting all three of those criteria is DoubleToIntFunction"

However, that is not the only functional interface that would allow the code to compile. You can also use ToIntFunction<Double> or ToIntFunction<Object>, and the code above will compile.



And ToIntFunction<Number>.
 
Jeanne Boyarsky
author & internet detective
Posts: 39129
723
Eclipse IDE Java VI Editor
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!