Java tutorial
//package com.java2s; import java.util.ArrayList; public class Main { /** * Subtract to vectors. * The size of v1 and v2 must be equal. * * @param v1 ArrayList with double values. * @param v2 ArrayList with double values. * @return new vector form v1 and v2. */ public static ArrayList<Double> subtractVector(ArrayList<Double> v1, ArrayList<Double> v2) { ArrayList<Double> returnValue = new ArrayList<>(); if (v1.size() == v2.size()) { for (int i = 0; i < v1.size(); i++) { returnValue.add(v1.get(i) - v2.get(i)); } } return returnValue; } }