throw
|
throws
|
Java throw keyword is used to
explicitly throw an exception.
|
Java throws keyword is used to
declare an exception.
|
Checked exception cannot be
propagated using throw only.
|
Checked exception can be
propagated with throws.
|
Throw is followed by an instance.
|
Throws is followed by class.
|
Throw is used within the method.
|
Throws is used with the method
signature.
|
You cannot throw multiple
exceptions.
|
You can declare multiple
exceptions
e.g.
public void method()throws IOException,SQLException |
Java throw example
- void m(){
- throw new ArithmetiException("sorry");
- }
Java throw and throws example
- void m()throws ArithmeticException{
- throw new ArithmeticException("sorry");
- }
No comments:
Post a Comment