这样写,public class 后面的名字按照你java文件的名字来,我的文件名叫test:
public class test {
double x, y, z;
test(double _x, double _y, double _z) {
x = _x;
y = _y;
z = _z;
}
double GetDistance() {
double Dis = x*x+y*y+z*z;
return Dis;
}
public static void main(String[] args) {
test Point = new test(1, 1, 1);
System.out.println(Point.GetDistance());
}
}