0

Difference between throw and throws in Java?

Throw specific runtime error', already know? Throws? Multiple runtime errors potentially arise? Throw single throws multiple Exception?

9th Feb 2023, 6:02 AM
Oliver Pasaribu
5 Réponses
+ 2
I think it is how English verbs (words) are used. And not Java specific.
9th Feb 2023, 9:06 AM
Paul
Paul - avatar
+ 2
Your question was not so clear. And you seem to know the answer.
9th Feb 2023, 11:24 AM
Paul
Paul - avatar
+ 1
throw is used to throw or propagate exception explicitly.. while throws used to declare exception that method might throw exception, it may be checked or unchecked. You can throw single exception with throw clouse. While you can declare multiple exceptions with throws.
9th Feb 2023, 12:19 PM
Jayakrishna 🇮🇳
0
Sorry? There is a throws and throw clause in Exception handling in Java. throws will cause jvm throw an Exception that potentially come when running the code, throw, cause Java throw specific Exception except you just throw Exception without mention what specific error'type you throw (e.g: IllegalArgumentException, IndexOutOfBoundException, DivideByZeroException, NullPointerException, etc).
9th Feb 2023, 10:17 AM
Oliver Pasaribu
0
Also there Will be a try-with-resource in Java Exception.
9th Feb 2023, 10:18 AM
Oliver Pasaribu