aspose file tools*
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 Java 8 in Action this week in the Java 8 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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: regarding arithmetic exception
 
Similar Threads
try-catch
Doubt in Exceptions.
Exception handling
tricky code snippet
Try/catch/finally