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

User Mittens
by
8.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
7.7k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.