throw vs throws in Java
Fast recall
Quick revision
Core answer
throw is a statement that transfers control by throwing one Throwable expression, such as throw new IllegalArgumentException("bad id"). throws is a method or constructor declaration listing exception types that may propagate. Declarations matter most for checked exceptions because callers must catch or declare them; listing an unchecked type is optional documentation.Whether you can crisply separate the runtime action (throw) from the compile-time declaration (throws)
Mixing up the keywords or thinking throws actually raises the exception
Note throws is only required for checked exceptions; unchecked ones need no declaration
Interview-ready guide
Interview answer
They're only one letter apart but they do completely different jobs, and they live on opposite sides of the process.
Throw, without an s, is an executable statement. It actually raises an exception at runtime. You write throw, then a new exception instance, and at that point control immediately jumps to the nearest matching catch block, or propagates up if there isn't one.
So throw takes a single exception object and fires it. Throws, with an s, is a declaration that goes in the method signature. It doesn't raise anything by itself — it just tells the compiler and anyone calling the method that this method might propagate these checked exceptions, so the caller needs to be prepared to either catch them or declare them in turn.
So throws takes a list of exception types, not an instance. A clean way to remember it: throw is what you do, throws is what you warn about. One important nuance is that throws is only required for checked exceptions.
If your method can propagate an I O exception and you're not catching it, you must declare throws I O exception, or the code won't compile. But for unchecked exceptions — anything extending RuntimeException, like IllegalArgumentException or NullPointerException — you never need a throws clause, even though you can still throw them.
So in a typical method you might use both: a throw statement in the body to raise an unchecked exception when an argument is invalid, and a throws clause in the signature to declare a checked exception that a library call might propagate. The mistake to avoid is thinking throws raises the exception or that throw declares it — they're strictly the runtime action versus the compile-time declaration.
throw vs throws in Java
Direct Answer
throw is a statement that transfers control by throwing one Throwable expression, such as throw new IllegalArgumentException("bad id"). throws is a method or constructor declaration listing exception types that may propagate. Declarations matter most for checked exceptions because callers must catch or declare them; listing an unchecked type is optional documentation.
Common Mistakes & Pitfalls
- Swapping the keywords.
throwraises one instance;throwslists types in the signature — they are not interchangeable. - Thinking
throwsraises the exception. It only declares the possibility; nothing is raised until athrowruns. - Adding
throwsfor unchecked exceptions. ARuntimeExceptionnever needs athrowsclause, even though you can stillthrowit. - Forgetting
throwsfor a checked exception you don't catch. That is a compile error, not a runtime one.
Check your understanding
Answer these without looking back at the article.
- Can you throw a checked exception without declaring throws?
- Can you have throws in the signature without actually throwing?
- Do you need throws for RuntimeException?
Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.