Can anyone please correct my given statement if its wrong(about throw/throws) [closed]

StackOverflow https://stackoverflow.com/questions/22603228

  •  19-06-2023
  •  | 
  •  

سؤال

THROW:-We have to handle the exception(we in the sense user here).

Throws:We are asking the compiler to handle the exception raised.

Please correct if what I stated above is wrong . If wrong please tell me the correct statement.

Thanks in Adv!

هل كانت مفيدة؟

المحلول

I'd say that both are not exact.

throw statement causes throwing of exception. No-one has to catch it however. For example runtime exception can be thrown without any requirement to catch them in application code.

throws is a keyword that allows to declare that method may throw exception of specific type.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top