This week's book giveaway is in the Features new in Java 9 forum.
We're giving away four copies of Java 9 Revealed and have Kishori Sharan on-line!
See this thread for details.
Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Doubt about errata ch6 p350: Error and RuntimeException (K&B7)  RSS feed

 
Prathima gaitonde
Ranch Hand
Posts: 130
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found this in here

ErrataKB7 wrote:page 350: 4th sentence in last paragraph
This sentence makes it sound like RuntimeException is a subclass of Error (which is of course not true). So RuntimeException should be replaced with any subclass of Error (e.g. StackOverflowError, NoClassDefFoundError, OutOfMemoryError,...)
Currently: When an Error or a subclass of Error (like RuntimeException) is thrown, it's unchecked.

Should be: When an Error or a subclass of Error (like StackOverflowError) is thrown, it's unchecked.


Just thought, can it be stated, like this?

Should be: When an Error or a subclass of RuntimeException is thrown, it's unchecked.
 
Roel De Nijs
Sheriff
Posts: 11077
173
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prathima gaitonde wrote:Just thought, can it be stated, like this?

Should be: When an Error or a subclass of RuntimeException is thrown, it's unchecked.

No, not in this context! In this paragraph (of the K&B7 study guide) the Error class is being discussed, the RuntimeException (and its subclasses) was already discussed on the top of page 350. So although the statement is correct (subclasses of RuntimeException are unchecked exception) it isn't appropriate to update the errata item in this way.

If you want to create one statement to summarize all unchecked exceptions, you'll end up with something like: When an Error or a RuntimeException or any of their subclasses is thrown, it's unchecked. But again, although spot-on this would not be an appropriate fix for the study guide, because this paragraph only discusses the Error class and was just wrongly using RuntimeException as a subclass of Error.

Hope it helps!
Kind regards,
Roel
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!