can I use the try...catch statement on java to stop the execution of codes on error? just like the exit sub on vb

Recommended Answers

All 5 Replies

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)
...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.