Which way is better for exception handling in your opinion, if statements or Try/Catch blocks?
Because, as you know, all exceptions can handled with if statements.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It depends on the situation. I’ll try to explain.
Consider this simple example:
OR
If
myVarcan benullas part of your code flow, then you can useifstatement, otherwise you should use the exception, because it probably caused because of things that were not under your control.