Java throw vs throws

Following table describe the difference between throw and throws.

1throw keyword is used to explicitly throw an exceptionthrows keyword is used to declare an exception
2throw is followed by an instance of Exception class
Syntax: throw new IllegalArgumentException(“Invalid input!!!”);
throws is followed by exception class name(s)
Syntax: throws IllegalArgumentException;
3throw keyword is used with in the method body to throw an exceptionthrows is used in method signature to declare the exceptions
4We cannot throw multiple exceptions
We can declare multiple exceptions
Scroll to Top