To throw an exception, we use the throw statement.
throw exceptionObject;
Semantics:
Throws an exception of the type indicated by the object appearing as parameter to the throw statement.
Example:
throw new MyException("message for MyException");
This statement throws an exception of type MyException, which prints on the screen the message that appears as parameter to the constructor.