0

How to catch multiple exceptions in a single catch block in Java?

I am using a try catch block and I dont want to use the method to catch Exception to catch all types of exceptions and I want to display the same message for all types of errors. Is there any way to catch multiple exceptions in a single catch box?

20th Aug 2018, 7:23 AM
Sahil Nayak
Sahil Nayak - avatar
3 Answers
+ 1
You can use one try block and some catch for example try { //} catch(one exception){} catch (second exception) {} ...
20th Aug 2018, 7:31 AM
Kapi
+ 1
if you want to display the same message for each error i don't see an issue with using: try{}catch{}
20th Aug 2018, 9:44 AM
hinanawi
hinanawi - avatar
0
Or just simply go on: try{} catch(Exception e){} It cathes every exception thats being thrown
20th Aug 2018, 7:19 PM
BalĂĄzs Rippl
BalĂĄzs Rippl - avatar