0
What is purpose of try and catch statement In java ?
2 Antworten
+ 4
Try/catch is to catch errors. Normally the program would just stop once it gets an error somewhere (for example wrong input or something). If there's an error inside the try it will continue with the catch-block and what's after.
+ 2
if/when an error happens while executing the code within the "try" block, the code within the "catch" block is executed (eg display error message, change the value of a variable...) instead of just crashing the program.