Java List Sum sumDifferences(List a, List b)

Here you can find the source of sumDifferences(List a, List b)

Description

sum Differences

License

Open Source License

Declaration

public static float sumDifferences(List<Double> a, List<Double> b) 

Method Source Code


//package com.java2s;
/*/*  www  .  j a  va2 s . c  o  m*/
 * Copyright 2013 Alibaba.com All right reserved. This software is the
 * confidential and proprietary information of Alibaba.com ("Confidential
 * Information"). You shall not disclose such Confidential Information and shall
 * use it only in accordance with the terms of the license agreement you entered
 * into with Alibaba.com.
 */

import java.util.List;

public class Main {
    public static float sumDifferences(List<Double> a, List<Double> b) {
        assert (a.size() == b.size());
        float sumDiff = 0f;
        //        double aSum = 0;
        //        double bSum = 0;
        for (int i = 0; i < a.size(); i++) {
            sumDiff += Math.abs(a.get(i) - b.get(i));
            //            aSum += a.get(i);
            //            bSum += b.get(i);
        }
        return (float) sumDiff;
    }
}

Related

  1. sum(List listOfNumbers)
  2. sum_ints(List list)
  3. sumAll(List list)
  4. sumAllColumnsOfMatrix(List> matrix)
  5. sumCreditList(List list)
  6. sumDouble(List list)
  7. sumInteger(List list)
  8. sumIntegers(List values)
  9. sumListItems(List list)