+ 2
Can someone explain me difference between 'throw' and 'throws' in Exception Handling? what is the need of 'throws'?
Would be great if someone explains with simple example.. Why do we need 'throws'? Why throw is not enough?
3 Antworten
+ 16
@throws is something like a warning. I'll try to explain it with methods:
If you call a method that is annotated with @throws the compiler knows that this call must be surrounded by try/catch.
throw is the keyword to actually throw a new exception in the method that is annotated with @throws.
+ 1
throws is a keyword that used to throw the runtime error to the os shell ,if you dont want to handle the error.