What is difference between throw and throws?
Page 1 of 1
What is difference between throw and throws?
throw keyword
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
throws keyword
throws is used to declare an exception.
checked exception can be propagated with throws.
throws is followed by class.
throws is used with the method signature.
You can declare multiple exception e.g. public void method()throws IOException,SQLException.
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
throws keyword
throws is used to declare an exception.
checked exception can be propagated with throws.
throws is followed by class.
throws is used with the method signature.
You can declare multiple exception e.g. public void method()throws IOException,SQLException.
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|