class Point{
double x,y,z;
Point(double _x, double _y, double _z){
x=_x;
y=_y;
z=_z;
}
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));
}
}
转载于:https://www.cnblogs.com/zhangqiang618/archive/2013/03/05/2945143.html