+ 1

Is there really a difference using throws statements or not?

If you delete the throws statement in the declaration the same result occurs! So why use it in the first place?

10th Feb 2017, 5:21 PM
Aziz
2 ответов
+ 2
Throws tells other programmers who use your methods, that these might throw an exception. They are forced to implement try/catch then - or another throw.
10th Feb 2017, 6:29 PM
Tashi N
Tashi N - avatar
0
There is definitely a very big difference using throws or without one. Whenever you want your code to catch the exception in the method where is your try block is you should have to use only throw. But if the situation is that, you want your code to catch the exception at the point from where method of the try block holder is called, you shoul have to use throws also.
11th Feb 2017, 6:45 PM
Rahmat Ali
Rahmat Ali - avatar