Euclidean Distance - Java Algorithm

Java examples for Algorithm:Number

Description

Euclidean Distance

Demo Code



public class EuclideanDistance {
    public static void main(String args[]) {
        double x1 = 7, x2 = 4;
        double y1 = 12, y2 = 6;
        double dis = Math.sqrt(Math.pow((x2 - x1), 2)
                + Math.pow((y2 - y1), 2));
        System.out.println("euclidean distance is " + dis);
    }/*from w  w w.j a va  2s . com*/

}

Related Tutorials