Many people say that checked exceptions (i.e. these that you should explicitly catch or rethrow) should not be used at all. They were eliminated in C# for example, and most languages don't have them. So you can always throw a subclass of RuntimeException (unchecked exception).

However, I think checked exceptions are useful - they are used when you want to force the user of your API to think how to handle the exceptional situation (if it is recoverable). It's just that checked exceptions are overused in the Java platform, which makes people hate them.

Here's my extended view on the topic.

As for the particular questions:

  1. Is the NumberFormatException considered a checked exception?
    No. NumberFormatException is unchecked (= is subclass of RuntimeException). Why? I don't know. (but there should have been a method isValidInteger(..))

  2. Is RuntimeException an unchecked exception?
    Yes, exactly.

  3. What should I do here?
    It depends on where this code is and what you want to happen. If it is in the UI layer - catch it and show a warning; if it's in the service layer - don't catch it at all - let it bubble. Just don't swallow the exception. If an exception occurs, in most of the cases, you should choose one of these:

  • log it and return
  • rethrow it (declare it to be thrown by the method)
  • construct a new exception by passing the current one in constructor
  1. Now, couldn't the above code also be a checked exception? I can try to recover the situation like this? Can I?
    It could've been. But nothing stops you from catching the unchecked exception as well.

  2. Why do people add class Exception in the throws clause?
    Most often because people are lazy to consider what to catch and what to rethrow. Throwing Exception is a bad practice and should be avoided.

Alas, there is no single rule to let you determine when to catch, when to rethrow, when to use checked and when to use unchecked exceptions. I agree this causes much confusion and a lot of bad code. The general principle is stated by Bloch (you quoted a part of it). And the general principle is to rethrow an exception to the layer where you can handle it.

Answer from Bozho on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-checked-vs-unchecked-exceptions
Java Checked vs Unchecked Exceptions - GeeksforGeeks
June 2, 2026 - Common examples include NullPointerException, ArithmeticException, and ArrayIndexOutOfBoundsException. Note: In Java, exceptions under RuntimeException and errors under Error are considered unchecked.
🌐
Oracle
docs.oracle.com › javase › tutorial › essential › exceptions › runtime.html
Unchecked Exceptions — The Controversy (The Java™ Tutorials > Essential Java Classes > Exceptions)
One case where it is common practice to throw a RuntimeException is when the user calls a method incorrectly. For example, a method can check if one of its arguments is incorrectly null. If an argument is null, the method might throw a NullPointerException, which is an unchecked exception.
Discussions

Exceptions - Checked vs Unchecked
There's a good article series on this at programming.guide. Difference between checked and unchecked exceptions explains the difference, with examples. Basically, checked exceptions are all those exceptions extending Exception (except RuntimeException and its subclasses.) Once you got that down, you'd probably want to read Choosing between checked and unchecked exceptions . Spoiler alert: Only under very specific circumstances would you want to go for a checked one. And, if you feel like really understanding the pro's and con's and the debate of whether checked exceptions is a good idea to begin with, check out https://programming.guide/java/checked-exceptions-good-or-bad.html . More on reddit.com
🌐 r/learnjava
3
3
April 29, 2020
If everyone hates checked exceptions, where's the alternative?
What you're observing is that for any endeavor, the haters often dominate the discourse, even when they don't have a majority position or a credible alternative. If they didn't hate on exceptions, they'd be whining about something else. Error handling is hard; there are many different approaches (C-style single return codes, Go-style multiple return codes, unchecked exceptions, checked exceptions, try monads, and more), and each has their pros and cons (and their supporters and haters), striking different balances of reliability and intrusiveness. Thinking there is One True Best Way here is fantasy. When people react to a particular error model, they are often reacting not to the approach itself, but examples they've encountered where it is used poorly. (Certainly Java has no shortage of examples of checked exceptions being misused.) The reality is that checked exceptions are OK, and they're what we've got, and, even if there was something that was slightly better, the disruption of trying to migrate billions of lines of code would make that impractical -- it would have to be massively better, and there's no such candidate on the horizon. Most developers intuitively realize this, and are not interested in dying on this hill, so you don't hear them in the vocal discourse, because they're too busy getting their work done. So if you want to know what to tell the newbies, tell them: don't take every rant seriously, some people just like to rant. More on reddit.com
🌐 r/java
93
16
April 25, 2024
Unchecked Java: Say Goodbye to Checked Exceptions Forever
really, after 20 more years of Java, I don't understand what's wrong with checked exceptions 😬😄 it's that annoying to catch them? More on reddit.com
🌐 r/java
71
54
July 13, 2023
Handling Checked Exceptions in Java Functional Interfaces (Lambdas)
Usually I either have ugly inline try catch blocks, a private method doing the same, or I make sure the method I call only uses unchecked exceptions - but it’s not ideal and and unfortunately a posterbook example of Java's design. More on reddit.com
🌐 r/java
78
39
September 23, 2024
Top answer
1 of 16
526

Many people say that checked exceptions (i.e. these that you should explicitly catch or rethrow) should not be used at all. They were eliminated in C# for example, and most languages don't have them. So you can always throw a subclass of RuntimeException (unchecked exception).

However, I think checked exceptions are useful - they are used when you want to force the user of your API to think how to handle the exceptional situation (if it is recoverable). It's just that checked exceptions are overused in the Java platform, which makes people hate them.

Here's my extended view on the topic.

As for the particular questions:

  1. Is the NumberFormatException considered a checked exception?
    No. NumberFormatException is unchecked (= is subclass of RuntimeException). Why? I don't know. (but there should have been a method isValidInteger(..))

  2. Is RuntimeException an unchecked exception?
    Yes, exactly.

  3. What should I do here?
    It depends on where this code is and what you want to happen. If it is in the UI layer - catch it and show a warning; if it's in the service layer - don't catch it at all - let it bubble. Just don't swallow the exception. If an exception occurs, in most of the cases, you should choose one of these:

  • log it and return
  • rethrow it (declare it to be thrown by the method)
  • construct a new exception by passing the current one in constructor
  1. Now, couldn't the above code also be a checked exception? I can try to recover the situation like this? Can I?
    It could've been. But nothing stops you from catching the unchecked exception as well.

  2. Why do people add class Exception in the throws clause?
    Most often because people are lazy to consider what to catch and what to rethrow. Throwing Exception is a bad practice and should be avoided.

Alas, there is no single rule to let you determine when to catch, when to rethrow, when to use checked and when to use unchecked exceptions. I agree this causes much confusion and a lot of bad code. The general principle is stated by Bloch (you quoted a part of it). And the general principle is to rethrow an exception to the layer where you can handle it.

2 of 16
257

Whether something is a "checked exception" has nothing to do with whether you catch it or what you do in the catch block. It's a property of exception classes. Anything that is a subclass of Exception except for RuntimeException and its subclasses is a checked exception.

The Java compiler forces you to either catch checked exceptions or declare them in the method signature. It was supposed to improve program safety, but the majority opinion seems to be that it's not worth the design problems it creates.

Why do they let the exception bubble up? Isnt handle error the sooner the better? Why bubble up?

Because that's the entire point of exceptions. Without this possibility, you would not need exceptions. They enable you to handle errors at a level you choose, rather than forcing you to deal with them in low-level methods where they originally occur.

🌐
Baeldung
baeldung.com › home › java › core java › checked and unchecked exceptions in java
Checked and Unchecked Exceptions in Java | Baeldung
January 8, 2024 - The Oracle Java Documentation provides guidance on when to use checked exceptions and unchecked exceptions: “If a client can reasonably be expected to recover from an exception, make it a checked exception. If a client cannot do anything to recover from the exception, make it an unchecked exception.” · For example, before we open a file, we can first validate the input file name.
🌐
Medium
medium.com › @AlexanderObregon › the-difference-between-checked-and-unchecked-exceptions-in-java-for-beginners-c3943786c40a
The Difference between Checked and Unchecked Exceptions in Java for Beginners
January 15, 2024 - Document the Exceptions: If your method can throw an unchecked exception, document this behavior in the method’s Javadoc to inform other developers. Here is a simple example of an unchecked exception (NullPointerException) and how it might occur:
🌐
BeginnersBook
beginnersbook.com › 2013 › 04 › java-checked-unchecked-exceptions-with-examples
Checked and unchecked exceptions in java with examples
Or Unchecked Exception can be handled only with try-catch blocks. ... Hi, you have mentioned that DataAccessException is a checked exception. However it is a runtime exception and that’s what makes it different from SQLException. ... Excellent explanations and Examples used, in few seconds got everything.
🌐
TheServerSide
theserverside.com › answer › What-are-checked-vs-unchecked-exceptions-in-Java
What are checked vs. unchecked exceptions in Java? | TheServerSide
If try-and-catch semantics are not required, it is known as an unchecked exception. A checked exception in Java represents a predictable, erroneous situation that can occur even if a software library is used as intended. For example, if a developer tries to access a file, the Java IO library forces them to deal with the checked FileNotFoundException.
Find elsewhere
🌐
Medium
medium.com › @ahmed.abdelfaheem › checked-and-unchecked-exceptions-in-java-6cb1c9815d32
Checked and Unchecked Exceptions in Java | by Ahmed Safwat | Medium
August 12, 2023 - Because unchecked exceptions typically indicate issues that should be fixed during development, they can often be avoided through proper coding practices, such as input validation and defensive programming. When working with exceptions in Java, it’s important to follow some best practices to ensure the maintainability and reliability of your code:
🌐
TechVidvan
techvidvan.com › tutorials › java-checked-and-unchecked-exception
Checked and Unchecked Exception in Java - Examples and Differences - TechVidvan
April 14, 2020 - According to the Oracle Java Documentation, there is a guide on when to use checked exceptions and unchecked exceptions: “If a client can reasonably be expected to recover from an exception, make it a checked exception. If a client cannot do anything to recover from the exception, make it an unchecked exception.” · For example, we can first validate the input file name before opening the file.
🌐
How to do in Java
howtodoinjava.com › home › exception handling › java checked vs unchecked exceptions
Java - Checked vs Unchecked Exceptions (with Examples)
December 20, 2022 - The code in the given program does not give any compile-time error. But when we run the example, it throws NullPointerException. NullPointerException is an unchecked exception in Java.
🌐
DataFlair
data-flair.training › blogs › java-exception
Java Exception - Explore Checked & Unchecked Exception With Examples - DataFlair
April 6, 2018 - 2. Unchecked Exception in Java: The exception classes inheriting the RuntimeException class are unchecked exceptions. They are not checked at compilation time but during runtime. For example: ArithmeticException, IndexOutOfBoundsException, etc.
🌐
Scientech Easy
scientecheasy.com › home › blog › checked and unchecked exceptions in java
Checked and Unchecked Exceptions in Java - Scientech Easy
January 19, 2026 - 3. Examples of checked exceptions are IOException, SQLException, ClassNotFoundException, etc whereas, examples of unchecked exceptions are ArithmeticException, ClassCastException, NullPointerException, IllegalArgumentException, etc.
🌐
Scaler
scaler.com › home › topics › checked and unchecked exception in java
Checked and Unchecked Exception in Java - Scaler Topics
February 11, 2022 - The exception is not caught or ... error message. InputMismatchException is a type of unchecked exception in Java, which is thrown when a program tries to read data of a different type than what is expected....
🌐
Scaler
scaler.com › home › topics › unchecked exception in java
What Is an Unchecked Exception in Java? - Scaler Topics
October 7, 2022 - In this example, instead of passing an int value for the age, the string value is passed. This caused an exception. ... If a developer does not want the error to be solved (considering it does not crash the system) then unchecked exceptions ...
🌐
PrepBytes
prepbytes.com › home › java › checked and unchecked exceptions in java
Checked and Unchecked Exceptions in Java
October 16, 2023 - Explanation: In this example, the main method is sleeping for one second using the Thread.sleep() method. If the sleep method is interrupted by another thread, the InterruptedException is thrown and caught in the catch block. Then we print the message "The thread was interrupted" on the console screen. In Java, unchecked exceptions are exceptions that the Java compiler does not enforce checking for.
🌐
Medium
medium.com › @niteeshboddapu › checked-vs-unchecked-exceptions-in-java-a-complete-guide-f9a78c18e5dd
Checked vs Unchecked Exceptions in Java — A Complete Guide | by Niteesh Boddapu | Medium
September 28, 2025 - Examples include IOException, SQLException, and ClassNotFoundException. import java.io.*; public class CheckedExample { public void readFile() throws IOException { FileReader reader = new FileReader("test.txt"); // may throw IOException } public ...
🌐
Rollbar
rollbar.com › home › how to handle checked & unchecked exceptions in java
How to Handle Checked & Unchecked Exceptions in Java
July 5, 2024 - Unchecked exceptions are like running out of gas or getting a flat tire. These are things that could happen due to your own oversight. You're not legally required to constantly check your fuel gauge or tire pressure, but if these problems occur, ...
🌐
DEV Community
dev.to › realnamehidden1_61 › whats-the-difference-between-checked-exception-and-unchecked-exception-in-java-977
⚠️ What’s the Difference Between Checked Exception and Unchecked Exception in Java? - DEV Community
October 23, 2025 - ... These are subclasses of RuntimeException. Analogy: Imagine texting while driving — the car suddenly swerves off the road. The problem wasn’t predictable by the system, but it happens due to poor coding habits or logic errors.
🌐
Coding Shuttle
codingshuttle.com › home › handbooks › java programming handbook › checked vs unchecked exceptions in java: ultimate guide
Checked vs Unchecked Exceptions in Java: Ultimate Guide | Coding Shuttle
July 24, 2025 - Exception caught: test.txt (No such file or directory) Explanation: Since reading a file is an external operation, Java forces us to handle IOException to avoid crashes. Unchecked exceptions are runtime exceptions that occur due to programming errors.
🌐
Reddit
reddit.com › r/learnjava › exceptions - checked vs unchecked
r/learnjava on Reddit: Exceptions - Checked vs Unchecked
April 29, 2020 -

A checked exception required a throw clause on the method header but not for the unchecked exception?

What is the difference between the two? How do I know if it is unchecked vs checked?