您好,欢迎访问一九零五行业门户网

java中point是什么意思

java问题 定义一个point点类 
定义一个point点类,成员变量有x,y,成员函数set()设置x,y的值,get()获取x,y的值,并定义一个点对象调用set()和get(),并定义一个点对象调用set()和get()构造方法重载,distance()表示2点间的距离。
实例
public class point { private int x; private int y; public point(int x, int y) { this.x = x; this.y = y; } public int getx() { return x; } public void setx(int x) { this.x = x; } public int gety() { return y; } public void sety(int y) { this.y = y; } public double distance(point p1,point p2){ return math.sqrt((p2.getx()-p2.getx())*(p2.getx()-p2.getx())+(p2.gety()-p1.gety())*(p2.gety()-p1.gety())); } public static void main(string args[]){ point p1 = new point(14,17); point p2 = new point(23,90); double s = p1.distance(p1,p2); system.out.println("2点之间的距离为:"+s); }}
以上就是java中point是什么意思的详细内容。
其它类似信息

推荐信息