• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

RuntimeException should be subclass of Error?

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've searched the JavaRanch archives, and I don't think this has been asked yet:
Does anyone think that RuntimeException would be better as a subclass of Error rather than Exception? I say this because it is unchecked like Error, and Exception is checked. Any thoughts?? It seems odd to me that RuntimeException is the only subclass of Exception that gets such special treatment. (Yes, I have read the JLS: JLS).
[ June 27, 2002: Message edited by: greg millward ]
 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
RuntimeExceptions occur when a condition is met which fails a runtime check, such as an array index being out of bounds or an illegal cast operation. These exceptions are grouped with normal checked exceptions because they are conditions that a reasonable application may try to catch.
Errors, on the other hand, differ in the fact that they, in general , represent conditions that an application should not try to catch. Errors are generally caused by some serious, albeit odd, occurance.
I hope that helps,
Corey
 
Craig Arthur
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Excellent point. I guess the JDK API says it all
Thanks for the quick response!
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Generally, exceptions are bugs in your code that can be handled with appropriately, or conditions that the compiler explicitly requests you to handle (such as InterruptedException and IOException.)
Errors, on the other hand, are conditions beyond the scope of your program, and thus shouldn't be handled by it (bad sectors in your hard drive, for example.)
 
Ranch Hand
Posts: 469
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Right,Errors generally include system errors,environmental problems,such as running out of memory.As with runtime exceptions,Java does not require that you state how these are to be handled.
Where as it is in progrmmer's hand to avoid runTime exceptions.Runtime exceptions like ArrayIndexOutOfBoundException,ArithmeticException would be avoided by correctly coding the program.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic