Home / Questions / How do you throw an exception?
Explanatory Question

How do you throw an exception?

👁 32 Views
📘 Detailed Answer
🕒 Easy to Read
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.

Answer with Explanation

An exception can be thrown using the throw keyword:


throw new ArithmeticException("Cannot divide by zero");