euclidean Distance - Java java.lang

Java examples for java.lang:Math Algorithm

Description

euclidean Distance

Demo Code


//package com.java2s;

import java.util.LinkedList;

public class Main {
    public static double euclideanDist(LinkedList<Double> a,
            LinkedList<Double> b) {
        double Sum = 0.0;
        for (int i = 0; i < a.size(); i++) {
            Sum = Sum + Math.pow((a.get(i) - b.get(i)), 2.0);
        }/*  w  w w .  ja va  2  s  .c  o m*/
        return Math.sqrt(Sum);
    }
}

Related Tutorials