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?
5 Antworten
+ 2
I think it is how English verbs (words) are used. And not Java specific.
+ 2
Your question was not so clear.
And you seem to know the answer.
+ 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.
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).
0
Also there Will be a try-with-resource in Java Exception.