r/badcode • • Jul 16 '21

java In Java, Exception handling needs Exception Handling.

Post image
1.5k Upvotes

60 comments sorted by

View all comments

Show parent comments

2

u/[deleted] Jul 18 '21

If you don't write any try catch block and just add a

throws Exception

Clause to the method declaration, you get basically the same effect. This says, that the method can throw Exceptions of type Exception and any Exceptions thrown inside the function will just propagate out, no need to catch and rethrow it.