F
fullofquestions
Hello everyone. I have encountered an issue that perhaps is related to
my setup. I am running NetBeans 6.0, jre1.6.04 and at the moment I was
going through a java book to document a whole bunch of topics. Anyway,
I created an extremely simple class to go over exception handling. The
issue is that I can't find a way for the instance to throw a
'java.lang.ArithmeticException: / by zero.' The following file
public class index {
public static void main( String args[] )
{
Scanner scanner = new Scanner( System.in ); // scanner for input
System.out.println("5/0.0 = " + 5/0.0);
System.out.println("5/0.0 = " + 5/0);
}
}
Produces the following output:
5/0.0 = Infinity
Exception in thread "main" java.lang.ArithmeticException: / by zero
What is the difference between dividing by 0(int) and 0.0(double)? If
I have a bunch of calculations involving doubles where I want to check
for div by zero, how shoud I go about it?
Why isn't my program throwing
my setup. I am running NetBeans 6.0, jre1.6.04 and at the moment I was
going through a java book to document a whole bunch of topics. Anyway,
I created an extremely simple class to go over exception handling. The
issue is that I can't find a way for the instance to throw a
'java.lang.ArithmeticException: / by zero.' The following file
public class index {
public static void main( String args[] )
{
Scanner scanner = new Scanner( System.in ); // scanner for input
System.out.println("5/0.0 = " + 5/0.0);
System.out.println("5/0.0 = " + 5/0);
}
}
Produces the following output:
5/0.0 = Infinity
Exception in thread "main" java.lang.ArithmeticException: / by zero
What is the difference between dividing by 0(int) and 0.0(double)? If
I have a bunch of calculations involving doubles where I want to check
for div by zero, how shoud I go about it?
Why isn't my program throwing