kodingwindow@kw:~$ javac KW.java kodingwindow@kw:~$ java KW
Exception in thread "main" java.lang.ArithmeticException: / by zero
at KW.main(KW.java:6)
kodingwindow@kw:~$
Java program to handle the ArithmeticException
KW.java
classKW{publicstaticvoidmain(Stringargs[]){intn=515,d=0;try{intresult=n/d;}catch(ArithmeticExceptione){System.out.println("Can't divide by zero");}}}
Output
kodingwindow@kw:~$ javac KW.java kodingwindow@kw:~$ java KW
Can't divide by zero
kodingwindow@kw:~$
Dear User, Thank you for visitng Kodingwindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.
Dear User, We are grateful for your interest in the Kodingwindow Android app. We intend to soon make it available on the Google Play Store. Currently, Android versions 10 and up require manual apk installations. Would you like to get the app?