File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes regarding arithmetic exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "regarding arithmetic exception" Watch "regarding arithmetic exception" New topic

regarding arithmetic exception

shreya prabhu
Ranch Hand

Joined: Feb 10, 2007
Posts: 31
int x=0;
int y=9/x;

catch(ArithmeticException ex)//line1
System.out.println("arithmetic exception");

i thought the ouput would be arithmetic exception finished
but at line 1 i am getting a error cannot convert from arithmeticexception to throwable.can anyone please clear my doubt
deepak adlakha
Ranch Hand

Joined: Jul 27, 2001
Posts: 325
i got this output when i ran this program.

java.lang.ArithmeticException: / by zero
arithmetic exception

I ran jdk 1.4.2_05 version.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
You code compiles and runs (on Java 6.0):

[ March 20, 2007: Message edited by: Barry Gaunt ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
I agree. Here's the link:
subject: regarding arithmetic exception
It's not a secret anymore!