Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.ArrayList;

public class Main {
    /**
     * Get the vectors magnitude.
     *      v {1, 2, 3}
     *      |v| 3.74...
     *
     * @param v values of vector as arraylist.
     * @return magnitude
     */
    public static double magnitudeVector(ArrayList<Double> v) {

        double vectorContent = 0;

        for (Double d : v) {
            vectorContent += Math.pow(d, 2);
        }

        return Math.sqrt(vectorContent);
    }
}