Java List Max max(List arg)

Here you can find the source of max(List arg)

Description

max

License

Apache License

Declaration

public static <V extends Comparable<V>> V max(List<V> arg) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Collection;

import java.util.List;

public class Main {
    public static <V extends Comparable<V>> V max(List<V> arg) {
        if (arg == null) {
            return null;
        }/*from   w w w.j  ava 2s.  c  o  m*/

        if (arg.size() == 1) {
            return arg.get(0);
        }

        V max = arg.get(0);
        for (V each : arg) {
            if (max.compareTo(each) < 0) {
                max = each;
            }
        }
        return max;
    }

    public static <V> int size(Collection<V> arg) {
        return null == arg ? 0 : arg.size();
    }
}

Related

  1. max(List list, int maximumSize)
  2. max(List runtimeList)
  3. max(List numberList)
  4. max(List numbers)
  5. max(List objectList)
  6. maxAbsVal(List vals)
  7. maxIndex( List list)
  8. maxIndex(List list)
  9. maxInnerSize(List> listOfLists)