Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What does checled exception mean?

 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm playing the Java Rule Round Up Game
 
Dale DeMott
Ranch Hand
Posts: 515
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A checked exection is any exception that is expected to be handled by the developer. If your compiler complains that an exception isn't handled in your code, then the exception you aren't handling is a checked exception. The compiler is 'checking' to see if you handled it in your code. Runtime exceptions are not checked. The compiler doesn't EXPECT you to handle them however you can catch them if you want.
 
Hemant Agarwal
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to create RunTime Exceptions in my code?
 
Michael Duffy
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Hemant Agarwal:
Is it possible to create RunTime Exceptions in my code?


of course, just have your exception extend java.lang.RuntimeException
 
Mike Noel
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or you can throw a RuntimeException with:



It's probably more useful to throw one of the RuntimeException subclasses like the UnsupportedOperationException.

_M_
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic