package a202; public class Point { double x, y; public Point(double x, double y){ this.x = x; this.y = y; } public double distanceTo(Point otherPoint){ double xLine = this.x - otherPoint.x; double yLine = this.y - otherPoint.y; double distance = Math.sqrt((xLine * xLine) + (yLine * yLine)); return distance; } public static double distanceBetween(Point pointA, Point pointB){ double xLine = pointA.x - pointB.x; double yLine = pointA.y - pointB.y; double distance = Math.sqrt((xLine * xLine) + (yLine * yLine)); return distance; } public static void main(String[] args){ Point a = new Point(3, 0); Point b = new Point(0, 4); System.out.println(Point.distanceBetween(a, b)); System.out.println(a.distanceTo(b)); } }