class Mypoint{
double x,y;
public Mypoint(double x,double y) {
this.x = x;
this.y = y;
}
public double distance(Mypoint mp) {
double x1 = this.x - mp.x;
double y1 = this.y - mp.y;
double tmp = x1y1 + y1y1;
return Math.sqrt(tmp);
}
}
class Test{
public static void main(String[] args) {
Mypoint p1 = new Mypoint(3,4);
Mypoint p2 = new Mypoint(8,9);
System.out.println("两点之间的距离为: "+p2.distance(p1));
}
}