Here you can find the source of distance(int xa, int ya, int xb, int yb)
public static double distance(int xa, int ya, int xb, int yb)
//package com.java2s; //License from project: Open Source License public class Main { public static double distance(int xa, int ya, int xb, int yb) { return Math.sqrt(distanceSquared(xa, ya, xb, yb)); }//from w ww. j a va2 s . c om public static int distanceSquared(int xa, int ya, int xb, int yb) { return square(xa - xb) + square(ya - yb); } public static int square(int i) { return i * i; } }