没听说有什么不同,是不是你1.4的classpath没有正确设置?
解决方案 »
- JAR文件是什么打开方式,我一个JAR文件不知道怎么打开
- 关于private是否被继承求解..
- 用java编写这样的输出 始终循环不出
- JAVA一个小程序的问题
- 请教 StringBuffer 使用问题,在线等!!!
- 安装好Microsoft SQL Server 2000 Driver for JDBC之后,如何进行JDBC的配置,才连接到SQL Server,对jsp或java应用程序文件才能进行运行
- 一个菜鸟问题:帮我看看这个关于“关闭窗口按钮”的问题吧!谢谢!
- 谁有这方面的算法或源码?高分相送!
- JIVE2。5。3+TOMCAT4。0的中文问题
- 寻找jbuilder3.5的注册码??请各位帮忙啊!!!
- 如何实现自定义异常类?请给个例子,比如:
- 如何使同一个JPanel里在不同时间段显示不同的控件
难道不对阿??
其实我就是编译wrox出的一本Beginning java2(jdk1.3)书上的代码.我把它贴出来.
他们分别是两个类!!每个类是一个独立的java文件!! 要编译的是有main方法的CreateSpheres类!!而Sphere类是CreateSpheres调用的!!! (javac CreateSpheres.java)public class CreateSpheres
{
public static void main(String[] args)
{
System.out.println("Number of objects =" + Sphere.getCount()); Sphere ball=new Sphere(4.0,0.0,0.0,0.0);
System.out.println("Number of objects ="+ ball.getCount());
Sphere globe=new Sphere(12.0,1.0,1.0,1.0);
System.out.println("Number of objects =" + globe.getCount()); //Output the volume of each sphere
System.out.println("ball volume=" + ball.volume());
System.out.println("globe volume =" + globe.volume());
}
}@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
public class Sphere{
static final double PI=3.14;
static int count=0; double radius;
double xCenter;
double yCenter;
double zCenter;
//Class constructor
Sphere(double theRadius,double x,double y,double z)
{
radius=theRadius; //Set the radius //Set the coordinates of the center
xCenter =x;
yCenter=y;
zCenter=z;
++count;
} //Static method to report the number of objects created
static int getCount()
{
return count;
} //Instance method to calculate volume
double volume()
{
return 4.0/3.0*PI*radius*radius*radius;
}}