+ 2

What is difference between throws and throw?

15th May 2020, 8:45 PM
SAIQA CHANNA
SAIQA CHANNA - avatar
2 Respostas
+ 2
With throw you can raise an exception. Throws can be added to method signatures, to indicate which kind of Exceptions have to be expected when using it. You would do that e.g. when you create a file reader method with general approach, so that you cannot or do not want to handle the follow up workflow, but let the caller decide how to act on exceptions occuring during file access.
15th May 2020, 9:07 PM
Manu_1-9-8-5
Manu_1-9-8-5 - avatar