throw

Showing posts with label throw. Show all posts
Showing posts with label throw. Show all posts

Throw vs throws in exception handling


Throw vs throws



Throw
Throws
Uses inside a method when it is required to throw an exceptionThis is used in the method signature in which methods that exceptions can occur. 
Only one exception can be thrownThrows can be used to declare multiple exceptions
Used to handle unchecked exceptionsUsed to handle checked exceptions
Usually used to handle custom exceptionsThrows means, it says this method can be thrown these exceptions, when you use this method, you need to handle it.