Java Collection Find findMax(Iterable collection)

Here you can find the source of findMax(Iterable collection)

Description

find Max

License

Open Source License

Declaration

public static <T extends Comparable<T>> T findMax(Iterable<T> collection) 

Method Source Code

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

import java.util.*;

public class Main {

    public static <T extends Comparable<T>> T findMax(Iterable<T> collection) {
        T max = null;//from  www.j ava 2  s  . c  om

        Iterator<T> it = collection.iterator();
        while (it.hasNext()) {
            T obj = it.next();
            if (null == max || max.compareTo(obj) < 0) {
                max = obj;
            }
        }

        return max;
    }
}

Related

  1. findCommonElementType(Collection collection)
  2. findCommonElementType(Collection collection)
  3. findCommonElementType(Collection collection)
  4. findMax(Collection vals)
  5. findMax(Collection vals)
  6. findValueOfType(Collection collection, Class type)
  7. findValueOfType(Collection collection, Class type)
  8. isAnyIncludedIn(Collection findAnyOfThese, Collection inThisCollection)