Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p><strong>Is it possible to figure out all possible exceptions that can be thrown that are not necessarily listed by the method's signature.</strong></p> </blockquote> <p>Simple answer: Not really. </p> <p>My answer is heavily based on <a href="http://docs.oracle.com/javase/tutorial/essential/exceptions/runtime.html" rel="nofollow">this document</a>, so I would suggest that you read this document to get an understanding of why Java designers didn't make it a necessity for you to handle all possible exception. The reasoning behind having <code>unchecked exception</code> as the document puts it: </p> <blockquote> <p>Runtime exceptions represent problems that are the result of a programming problem, and as such, the API client code cannot reasonably be expected to recover from them or to handle them in any way. Such problems include arithmetic exceptions, such as dividing by zero; pointer exceptions, such as trying to access an object through a null reference; and indexing exceptions, such as attempting to access an array element through an index that is too large or too small.</p> <p>Runtime exceptions can occur anywhere in a program, and in a typical one they can be very numerous. Having to add runtime exceptions in every method declaration would reduce a program's clarity. Thus, the compiler does not require that you catch or specify runtime exceptions (although you can).</p> </blockquote> <p>So, in my opinion, looking out for all possible exception wouldn't be a good idea. For example, it doesn't make sense to <code>OutOfMemoryError</code>. In fact, it is also considered a bad practice to catch such an exception. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload