Throwing an exception in Java - Java tutorial
Throwing An Exception
You can throw an exception explicitly using the throw statement.
For e.g.
You need to throw an exception when a user enters a wrong login ID or password.
The throws clause is used to list the types of exception that can be thrown during the execution of a method in a program.