Try Without Catch in Java
Fast recall
Quick revision
Core answer
try is legal with just a `finally` block and no catch — try { ... } finally { ... }. You'd use it for structured cleanup while letting the exception propagate to the caller. (try-with-resources can also stand alone.) What's illegal is a try with neither catch nor finally — that won't compile.Whether you know try needs at least one of catch or finally, and that try-finally (no catch) is a valid, useful pattern
Believing every try must have a catch, or not realising try-finally lets the exception still propagate
Explain that try-finally is exactly how you do cleanup without handling — you release the resource but let the caller decide what to do with the error
Interview-ready guide
Interview answer
Yes, you can absolutely have a try without a catch.
The actual rule in Java is that a try block has to be followed by at least one of three things: one or more catch blocks, a finally block, or, since Java 7, it can be a try-with-resources statement. What you can't have is a try with nothing after it — a bare try block on its own is a compile error.
So the form that surprises freshers is try-finally with no catch in between. That pattern is genuinely useful, and the use case is when you want structured cleanup but you don't actually want to handle the exception at this level. A classic example is acquiring a lock: you lock, then in the try you do your work, and in the finally you unlock.
There's no catch, so if the work throws, the finally still runs and releases the lock, and then the exception propagates up to whoever called you. That's the key point — the finally doesn't consume or swallow the exception, it just guarantees the cleanup happens before the exception leaves the method. The caller, which is usually in a better position to decide what to do, still receives the error.
A mistake I'd warn against is adding an empty catch block just to make the code compile, because that silently swallows the exception and hides bugs. If all you need is cleanup, use try-finally rather than an empty catch. And these days, for things that implement AutoCloseable like streams or J D B C connections, try-with-resources is even cleaner because it closes the resource for you automatically.
Try Without Catch in Java
Direct Answer
Yes. A try is legal with just a finally block and no catch — try { ... } finally { ... }. You'd use it for structured cleanup while letting the exception propagate to the caller. (try-with-resources can also stand alone.) What's illegal is a try with neither catch nor finally — that won't compile.
Common Mistakes & Pitfalls
- Assuming every
tryneeds acatch. It only needscatchorfinally(or resources). - Adding an empty
catchjust to compile. That swallows the exception silently — usetry-finallyinstead if you only need cleanup. - Forgetting the exception still propagates in
try-finally—finallydoesn't 'consume' it. - Writing a bare
try {}— it won't compile.
Check your understanding
Answer these without looking back at the article.
- When would you use try-finally instead of try-catch-finally?
- How does try-with-resources replace try-finally for resource cleanup?
- Can you nest try blocks inside a finally block?
Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.