This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "regarding arithmetic exception" Watch "regarding arithmetic exception" New topic
Author

regarding arithmetic exception

shreya prabhu
Ranch Hand

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

}
catch(ArithmeticException ex)//line1
{
System.out.println(ex.toString());
System.out.println("arithmetic exception");
}
System.out.println("finished");

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
finished


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.
 
Don't get me started about those stupid light bulbs.
 
subject: regarding arithmetic exception
 
Similar Threads
try-catch
Exception handling
Try/catch/finally
Doubt in Exceptions.
tricky code snippet