Difference between throw and throws keyword in java exception handling
| S.No | throw | throws |
|---|---|---|
| 1 | Throw keyword is used to create a new Exception object and throw it | Throws keyword is used in method definition, to declare that a method can throw this kind of exception. |
| 2 | Using throw keyword you can declare only one Exception at a time. | Using throws keyword you can declare multiple exception at a time. |
Summary
So here we are, we hope now you got to know difference between throw and throws keyword in Exceptions in java.
We tried our best to simplify the explanation, if you feel any difference or you need help in understanding any such thing, then feel free to contact us through email and subscribe to ProgrammerToday.