形参放置类变量案例
public class TestPoint {
int x,y,z;public TestPoint(int _x,int _y,int _z){
x=_x;
y=_y;
z=_z;
}
/*
public void setX(int x){this.x=x;
}
public void setY(int y){
this.y=y;
}
public void setZ(int z){
this.z=z;
}
*/
public double conut (TestPoint s){double result=Math.sqrt((x-s.x)*(x-s.x)+(y-s.y)*(y-s.y)+(z-s.z)*(z-s.z));
return result;
}
public static void main(String[] args){
TestPoint s1=new TestPoint(3,4,5);
TestPoint s2=new TestPoint(3,9,5);
System.out.println(s1.conut(s2));
}
}