+ 4
Try catch throw definition java help
did i understand them correctly,correct me if im wrong (try)-write the code within the type that you think an exception might occur. (catch)-receive the exception from try and do the neccessary steps given to it like " catch(Exception e){System.out.println("you did it wrong");". (throw)-coder will write the specific exception error inside the throw.if that exception really happens,it will show the exception error that the coder has written in the output.so we decide how the error will look like
2 Answers
0
The try and catch portions are correct, the throw I am not entirely sure on as i have only used Try {}Catch {} in my code.
0
throw will throw the exception you put there yes. It behaves like a usual exception. So unless you catch it, it will crash your program.
That's why it is discouraged.