Throw vs throws in exception handling
Throw vs throws
Throw | Throws |
Uses inside a method when it is required to throw an exception | This is used in the method signature in which methods that exceptions can occur. |
Only one exception can be thrown | Throws can be used to declare multiple exceptions |
Used to handle unchecked exceptions | Used to handle checked exceptions |
Usually used to handle custom exceptions | Throws means, it says this method can be thrown these exceptions, when you use this method, you need to handle it. |
0 comments :
Post a Comment