Home > DeveloperSection > Forums > Difference between throw and throws keyword in Java
Royce Roy
Royce Roy

Total Post:149

Posted on    April-15-2015 12:38 AM

 Java Java 

 1 Reply(s)
 855  View(s)
Rate this:
what is difference between throw and throws keyword in Java

Mayank Tripathi
Mayank Tripathi

Total Post:397

Posted on    April-15-2015 1:12 AM

1)throw is used to explicitly throw an exception.
2)checked exceptions can not be propagated with throw only.
3)throw is followed by an instance.
4)throw is used within the method.
5)You cannot throw multiple exception

1)throws is used to declare an exception.
2)checked exception can be propagated with throws.
3)throws is followed by class.
4)throws is used with the method signature.
5)You can declare multiple exception e.g. public void method()throws IOException,SQLException.

Don't want to miss updates? Please click the below button!

Follow MindStick