Java Vector Sum vectorSum(int[] vector)

Here you can find the source of vectorSum(int[] vector)

Description

vector Sum

License

Open Source License

Declaration

public static int vectorSum(int[] vector) 

Method Source Code

//package com.java2s;
/*//from   w  ww.  j  a  va2s. co m
 * Created on 12.12.2004
 * 
 * COPYRIGHT NOTICE
 * 
 * Copyright (C) 2005 DFKI GmbH, Germany
 * Developed by Benedikt Fries, Matthias Klusch
 * 
 * The code is free for non-commercial use only.
 * You can redistribute it and/or modify it under the terms
 * of the Mozilla Public License version 1.1  as
 * published by the Mozilla Foundation at
 * http://www.mozilla.org/MPL/MPL-1.1.txt
 */

public class Main {
    public static int vectorSum(int[] vector) {
        int sum = 0;
        for (int i = 0; i < vector.length; i++)
            sum += vector[i];
        return sum;
    }

    public static double vectorSum(double[] vector) {
        double sum = 0;
        for (int i = 0; i < vector.length; i++)
            sum += vector[i];
        return sum;
    }
}

Related

  1. vectorSum(final double[] vecOne, final double[] vecTwo)