Posted By:
mandeep_singh
Posted On:
Sunday, April 23, 2006 04:38 AM
I am compiling following program. public class Speed { public static void main(String[] args) { Speed objRef=new Speed(); double speed=objRef.calcSpeed(-12.0,3.0); //double speed=objRef.calcSpeed(12.0,-3.0); //double speed=objRef.calcSpeed(12.0,2.0); //double speed=objRef.calcSpeed(12.0,0.0); System.out.println("Speed(km/h):"+speed); } private double calcSpeed(double distance,double time) { assert distance>=0.0; assert time>0.0:"Time is not a positive value:"+time; double speed=distance/time; assert speed>=0.0; return speed; } } javac -source 1.4 Speed.java F
More>>
I am compiling following program.
public class Speed
{
public static void main(String[] args)
{
Speed objRef=new Speed();
double speed=objRef.calcSpeed(-12.0,3.0);
//double speed=objRef.calcSpeed(12.0,-3.0);
//double speed=objRef.calcSpeed(12.0,2.0);
//double speed=objRef.calcSpeed(12.0,0.0);
System.out.println("Speed(km/h):"+speed);
}
private double calcSpeed(double distance,double time)
{
assert distance>=0.0;
assert time>0.0:"Time is not a positive value:"+time;
double speed=distance/time;
assert speed>=0.0;
return speed;
}
}
javac -source 1.4 Speed.java
Folloing error occurs on command prompt.
An UnExpected Error detected by HotSpot Virtual Machine:
#
# EXCEPTION_FLT_DIVIDE_BY_ZERO (0xc000008e) at pc=0x00c2aa53, pid=1368, tid=1384
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_05-b05 mixed mode, sharing)
# Problematic frame:
# j com.sun.tools.javac.jvm.Items$ImmediateItem.isPosZero(D)Z+0
#
<<Less