can I use the try...catch statement on java to stop the execution of codes on error? just like the exit sub on vb
stop the execution of codes on error
It works the opposite way. A catch can allow the program to continue executing when there is an error. Go to this site and read up:
hmmm.. so what statement should I use? coz i'm trying to stop the execution of code when an error occurs
The exception will stop the execution of code at the point of the error.
The catch will "catch" the execution and allow the program to continue executing in the catch block's code.
okay, gonna try it,
but, off course, if you write in your catch-block some statements that will exit the program, you can there end your program any way you want:
displaying a stacktrace
not displaying a stacktrace
giving an error message (popup)