Tuesday 17 November 2015

Difference b/w throw and throws


S.No
Throw
Throws
1
Throw is used to explicitly throw an exception
Throws is used to declare an exception
2
checked exception cannot be propagated without throws
checked exception can be propagated with throws
3
Throw is followed by an instance
Throws is followed by class
4
Throw is used within the method
Throws is used with the method signature
5
You cannot throw multiple exception
You can declare multiple exception e.g. public void method()throws IOException,SQLException

No comments:

Post a Comment