About 68,700 results
Open links in new tab
  1. Most common checked and unchecked Java Exceptions?

    Aug 12, 2009 · How about looking for subclasses of java.lang.exception, for example here Personally I use 2 checked exceptions of my own TransientException for cases when a retry might work. And InvalidRequestException for validation errors.

  2. Understanding checked vs unchecked exceptions in Java

    String s = "abc"; Object o = s; Integer i = (Integer) o; Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer at Sample.main(Sample.java:9) Here exception is due to bad data and in no way it can be determined during compile time.

  3. How to find potential unchecked exceptions in Java?

    Nov 19, 2016 · 1 - These caveats are: 1) the analyser needs to be aware of the Java language constructs that can throw unchecked exceptions implicitly; e.g. instance method call can throw a NPE, a new can throw an OOOME, etc. 2) you need to analyse all library methods used by your code, including 3rd-party libraries, 3) Java exceptions could be thrown from ...

  4. java - how to handle unchecked exceptions? - Stack Overflow

    Apr 19, 2017 · I'm having difficulties understanding how to handle unchecked exceptions. If the method doesn't declare the exception and I am not forced to handle it, how do I even know the method throws an exception? Unchecked exceptions are for programming errors, as I have read, so to avoid a NullPointerException, I would introduce

  5. java - When to choose checked and unchecked exceptions - Stack …

    The reason is it will not clutter application code with try-catch and throws declaration on method. If your application is using Java Api which throws checked exceptions that anyways need to be handle. For other cases, the application can throw unchecked exception. If the application caller still needs to handle unchecked exception, it can be done.

  6. java - Differences between …

    Apr 23, 2015 · Exceptions are two types in java: 1. **Checked Exception: The exceptions which are checked by compiler. For example: we you are performing operation with file, then compiler will ask you to handle IOException either by try-catch block or throws keyword. 2. Unchecked Exception: The exceptions which are not checked by compiler at run time.

  7. java - Should I declare unchecked exceptions in the throws ...

    Jan 1, 2014 · If for some reason I can reasonably expect an unchecked exception to occur in a method, should I add it to the throws specification? Since unchecked exceptions indicate programming errors, declaring them in the throws clause should be avoided. Generally, catching these exceptions should not be attempted, except for the highest level of your ...

  8. java - How do I address unchecked cast warnings? - Stack Overflow

    An unchecked exception could turn into a CCE at any point later on instead of the point of the cast (that's the reason why it's a separate warning). Replace the HashMap with a dedicated class:

  9. Checked vs Unchecked Exceptions in Java - Stack Overflow

    Dec 23, 2012 · Use unchecked exception when client code cannot do anything. For example, convert your SQLException into another checked exception if the client code can recover from it and convert your SQLException into an unchecked (i.e. RuntimeException) exception, if the client code cannot do anything about it.

  10. How to find a list of possible Java Exceptions - Stack Overflow

    Jul 9, 2015 · If you don't handle checked exception you will get a build failure. You can identify checked exception if you are using any IDE. But unchecked exception are bit tricky and you may need to refer the API documentation to understand what they are, because unless it's thrown you may not know that exception can occur.

Refresh