Java List Sum sum(List list)

Here you can find the source of sum(List list)

Description

Sum List array

License

Open Source License

Parameter

Parameter Description
list List

Return

long result sum of all List elements

Declaration

public static long sum(List<? extends Length> list) 

Method Source Code

//package com.java2s;
/*// w  w  w  . j a v  a  2s.  com
 * Java Bittorrent API as its name indicates is a JAVA API that implements the Bittorrent Protocol
 * This project contains two packages:
 * 1. jBittorrentAPI is the "client" part, i.e. it implements all classes needed to publish
 *    files, share them and download them.
 *    This package also contains example classes on how a developer could create new applications.
 * 2. trackerBT is the "tracker" part, i.e. it implements a all classes needed to run
 *    a Bittorrent tracker that coordinates peers exchanges. *
 *
 * Copyright (C) 2007 Baptiste Dubuis, Artificial Intelligence Laboratory, EPFL
 *
 * This file is part of jbittorrentapi-v1.0.zip
 *
 * Java Bittorrent API is free software and a free user study set-up;
 * you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Java Bittorrent API is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Java Bittorrent API; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * @version 1.0
 * @author Baptiste Dubuis
 * To contact the author:
 * email: baptiste.dubuis@gmail.com
 *
 * More information about Java Bittorrent API:
 *    http://sourceforge.net/projects/bitext/
 */

import sun.security.util.Length;

import java.util.*;

public class Main {
    /**
     * Sum List array
     * @param list List
     * @return long result sum of all List elements
     */
    public static long sum(List<? extends Length> list) {
        long sum = 0;
        for (Object i : list) {
            sum += ((Length) i).length();
        }
        return sum;
    }
}

Related

  1. removeOne(List summary, int start)
  2. sum(final List list1, final List list2)
  3. sum(final List list)
  4. sum(final List list)
  5. sum(int[] list)
  6. sum(List a)
  7. sum(List data)
  8. sum(List scores)
  9. sum(List vals)