我的代码
public class Point { private int x; private int y; private int z; public Point(int _x,int _y,int _z){ x = _x; y = _y; z = _z; } public void setX(int i){ x = i; } public void setY(int i){ y = i; } public void setZ(int i){ z = i; } public double distance(){ return Math.sqrt( x*x+y*y+z*z); } public static void main(String[] args) { Point p1 = new Point(1,2,3); System.out.println(p1.distance()); } }