Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General 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_
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic