Results 1 to 4 of 4
  1. #1
    Zarah is offline Senior Member
    Join Date
    Mar 2014
    Posts
    286
    Rep Power
    7

    Default How do we know when an Error (an unchecked exception) can occur?

    Checked Exceptions have a try or catch requirement, so the compiler notifies us when we call a method in which a checked exception can occur, and don't define an exception handler or declare our method (in which we are calling the method in which the exception can occur) to throw that exception.

    But what about the Errors (Error and its subclasses represent unchecked exceptions, along with RuntimeException)? How would we know that an Error could occur at a certain point, and that we should define a handler there? Is it just a guessing game?

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,422
    Blog Entries
    7
    Rep Power
    28

    Default Re: How do we know when an Error (an unchecked exception) can occur?

    There's no need guessing: read the API documentation for the particular method in that particular class.

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

  3. #3
    Zarah is offline Senior Member
    Join Date
    Mar 2014
    Posts
    286
    Rep Power
    7

    Default Re: How do we know when an Error (an unchecked exception) can occur?

    @JosAH Thank you very much.

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,422
    Blog Entries
    7
    Rep Power
    28

    Default Re: How do we know when an Error (an unchecked exception) can occur?

    You're welcome of course; note that there are two camps here: the folks who want every type of Exception to be checked; they want to be handheld by the compiler; those are the sissies; and there are the real men (like me) who don't need checked Exceptions, nor want them, they can do without them (as in C++).

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

Similar Threads

  1. Replies: 6
    Last Post: 05-21-2015, 11:19 AM
  2. Basis for making exception as checked or unchecked
    By jmohandos304 in forum New To Java
    Replies: 1
    Last Post: 10-10-2014, 02:32 PM
  3. Error occur while installing Eclipse
    By samantasmita in forum Eclipse
    Replies: 1
    Last Post: 01-05-2012, 02:24 PM
  4. Compile error - unchecked
    By pahiker in forum New To Java
    Replies: 18
    Last Post: 06-24-2010, 09:27 AM
  5. UnChecked Exception
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-18-2007, 07:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •