Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is try/catch is resources consuming operation?

Tags:

java

I heard that instead of throwing exceptions and catching them in try/catch block it is more reasonable to return null in methods instead because try/catch is resources consuming operation. Is this true?

like image 818
Eugene Avatar asked Dec 29 '10 08:12

Eugene


1 Answers

Try/catch only takes a significant amount of resources if there is an exception thrown, otherwise it's practically none. Use them when they make the program cleaner. Returning null can be OK too. It depends

like image 60
Falmarri Avatar answered Nov 15 '22 20:11

Falmarri