Java Array Absolute Value abs_sum(int[] data)

Here you can find the source of abs_sum(int[] data)

Description

Return sum of absVal of each index

License

Open Source License

Parameter

Parameter Description
data a parameter

Declaration

public static int abs_sum(int[] data) 

Method Source Code

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

public class Main {
    /**// www.j  a v  a 2 s .  c  o m
     * Return sum of absVal of each index
     * 
     * @param data
     * @return
     */
    public static int abs_sum(int[] data) {
        int sum = 0;
        for (int i = 0; i < data.length; i++) {
            sum += Math.abs(data[i]);
        }
        return sum;
    }
}

Related

  1. absAvg(double[] inputArray, int divisions, int cap)
  2. absDiff(Double[] a, Double[] b)
  3. absMax(double x, double y)
  4. absMax(double[] arr)