• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Checked exception

 
sparsh khandelwal
Ranch Hand
Posts: 76
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the meaning of the line that checked exception can not forward in calling chain
ScreenShot002.jpg
[Thumbnail for ScreenShot002.jpg]
 
Junilu Lacar
Bartender
Pie
Posts: 6529
21
Java Linux Mac Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please QuoteYourSources (←click) ... I have no idea what that's supposed to mean either.
 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12015
24
Chrome Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
screenshots like that are VERY hard for some of us to read. Can you past the test into a post instead?
 
sparsh khandelwal
Ranch Hand
Posts: 76
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is the linklink
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With checked exceptions, you must either catch them, or explicitly specify that the method inside which the exception might be thrown, passes it on the the calling method, by using a throws clause in the method declaration.

For example, if you have a method that throws a checked exception such as IOException:

This will not compile, because the method does not catch the exception, and it also doesn't have a throws clause. You have to fix it, for example like this:

See The Catch or Specify Requirement.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47228
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting déjà vu. Is that the same website we told you to avoid recently?
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:I am getting déjà vu. Is that the same website we told you to avoid recently?


Wow. Awful indeed. His two main points on that page, "By rule, unchecked/checked exceptions are/are not propagated," are nonsense. The rules for propagation are exactly the same for every exception: If it's not caught, it bubbles up to the next nearest enclosing try block. That's the runtime behavior of every exception. The compile-time catch-or-declare rule for checked exceptions is a separate issue from that.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic