Java List Average addAverage(List list, int InColumn1, int InColumn2, int resultColumn)

Here you can find the source of addAverage(List list, int InColumn1, int InColumn2, int resultColumn)

Description

InColumn1 / InColumn2 = resultColumn.

License

Open Source License

Declaration

public static List<Object[]> addAverage(List<Object[]> list, int InColumn1, int InColumn2, int resultColumn) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.List;

public class Main {
    /** InColumn1 / InColumn2 = resultColumn. ResultColumn will be a double. */
    public static List<Object[]> addAverage(List<Object[]> list, int InColumn1, int InColumn2, int resultColumn) {
        for (Object[] objects : list) {
            // TODO check math rounding
            double div = Double.valueOf(objects[InColumn1].toString());
            double div2 = Double.valueOf(objects[InColumn2].toString());

            if (div2 != 0) {
                objects[resultColumn] = div / div2;
            }// w ww.j a va  2s. c  o m
        }

        return list;
    }
}

Related

  1. average(final List vals, final int maxI)
  2. average(List collected)
  3. average(List arr)
  4. average(List list)