java代码在cmd下执行无误,但是在Eclipse中执行报错
本人java新手,练习代码在cmd下执行无误,但是在Eclipse中实行报错,代码如下:classPoint{doublex;doubley;doublez;Point(...
本人java新手,练习代码在cmd下执行无误,但是在Eclipse中实行报错,代码如下:
class Point {
double x;
double y;
double z;
Point (double x1,double y1,double z1) {
x = x1;
y = y1;
z = z1;
}
void setx(double x1) {x = x1;}
void sety(double y1) {y = y1;}
void setz(double z1) {x = z1;}
double getdistance (Point p) {
return (x - p.x) * (x - p.x) + (y - p.y) * (y - p.y) + (z- p.z) * (z - p.z);
}
}
public class TestPoint {
public static void main(String[] args) {
Point p = new Point(1.0, 2.0, 3.0);
Point p1 = new Point(0.0, 0.0, 0.0);
System.out.println(p.getdistance(p1));
p.setx (5.0);
System.out.println(p.getdistance(new Point(1.0, 2.0, 3.0)));
}
}
错误提示:
Exception in thread "main" java.lang.NoSuchMethodError: Point.<init>(DDD)V
at TestPoint.main(TestPoint.java:20) 展开
class Point {
double x;
double y;
double z;
Point (double x1,double y1,double z1) {
x = x1;
y = y1;
z = z1;
}
void setx(double x1) {x = x1;}
void sety(double y1) {y = y1;}
void setz(double z1) {x = z1;}
double getdistance (Point p) {
return (x - p.x) * (x - p.x) + (y - p.y) * (y - p.y) + (z- p.z) * (z - p.z);
}
}
public class TestPoint {
public static void main(String[] args) {
Point p = new Point(1.0, 2.0, 3.0);
Point p1 = new Point(0.0, 0.0, 0.0);
System.out.println(p.getdistance(p1));
p.setx (5.0);
System.out.println(p.getdistance(new Point(1.0, 2.0, 3.0)));
}
}
错误提示:
Exception in thread "main" java.lang.NoSuchMethodError: Point.<init>(DDD)V
at TestPoint.main(TestPoint.java:20) 展开
3个回答
2014-11-14
展开全部
eclipse里面是不是启用了严格检查。。。。。。。还是项目类型不对应呢。。。。。。
换成public定义
public Point (double x1,double y1,double z1) {
传参数的地方,换成 1.0D, 2.0D, 3.0D 试试
换成public定义
public Point (double x1,double y1,double z1) {
传参数的地方,换成 1.0D, 2.0D, 3.0D 试试
追问
还是不行啊,你运行报错么?
追答
JDK 1.6 不报错,正常
检查检查项目属性里面的设置
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询