228k views
0 votes
A program to illustrate exceptional handling​

User Mittens
by
5.1k points

1 Answer

3 votes

You surround your part of the program that can throw exceptions with a

try { ... } block and place a catch(...) { ... } directly below it.

You could put code in the try block that divides by zero to see an exception in action. Alternatively, you can throw one yourself using the throw keyword.

User Marco Minerva
by
4.5k points