What is the Difference Between Throw and Throws in Java ?

Java provides throw keyword to throw an exception from a method or a static block. Java provides throws keyword to mention the probable exception thrown by a method in its declaration.

We use throw to explicitly throw an exception. We used throws to declare an exception in method definition.

We cannot propagate checked exceptions with throw only. But checked exceptions can be propagated with throws keyword.

A throw call is followed by an instance. Class or Exception follows a throws keyword.

Call to throw occurs within a method. throws is just used with method signature.

We can throw only one exception at a time. But we can mention as many exceptions in throws clause.



You May Interest

How Will You Make an Object Immutable in Java ?

What is the Difference Between Sleep and Wait Methods in Java ?

Java How To Find The Average Of 10 Numbers Using A While Loop

How Will You Define the Scope of a Bean in Spring ?

What is the Difference Between Abstract Class and Interface in Ja ...