0
throw Exception
What is the difference between using throw new ArithmeticException("Division by Zero");and print ?
2 Antworten
+ 1
Throwing will handle the exception, "Division by Zero" is simply the message printed for the exception.
Print will merely print the message, and the program will most likely crash due to the unhandled exception.
0
And "throw" keyword is used throw an exception to the calling method where this exception can be handled using try/catch block and it is mainly used for user defined exception based on some condition where as "print" is just used to print some output or some message.