Java List Max maxInt(List array)

Here you can find the source of maxInt(List array)

Description

max Int

License

Open Source License

Declaration

public final static int maxInt(List<Integer> array) 

Method Source Code

//package com.java2s;

import java.util.List;

public class Main {
    public final static int maxInt(List<Integer> array) {
        if (array.size() == 0)
            return 0;
        int res = array.get(0);
        for (int i = 1; i < array.size(); i++) {
            res = Math.max(res, array.get(i));
        }/*from w  ww  . ja v  a  2s  . com*/
        return res;
    }

    public final static byte max(byte[] array) {
        if (array.length == 0)
            return 0;
        byte res = array[0];
        for (int i = 1; i < array.length; i++) {
            res = (byte) Math.max(res, array[i]);
        }
        return res;
    }

    public final static double max(double[] array) {
        if (array.length == 0)
            return 0;
        double res = array[0];
        for (int i = 1; i < array.length; i++) {
            res = Math.max(res, array[i]);
        }
        return res;
    }

    public final static double max(double[][] array, int col) {
        if (array.length == 0)
            return 0;
        double res = array[0][col];
        for (int i = 1; i < array.length; i++) {
            res = Math.max(res, array[i][col]);
        }
        return res;
    }

    public final static double max(float[][] array, int col) {
        if (array.length == 0)
            return 0;
        float res = array[0][col];
        for (int i = 1; i < array.length; i++) {
            res = Math.max(res, array[i][col]);
        }
        return res;
    }

    public final static int max(int[] array) {
        if (array.length == 0)
            return 0;
        int res = array[0];
        for (int i = 1; i < array.length; i++) {
            res = Math.max(res, array[i]);
        }
        return res;
    }
}

Related

  1. max(List arg)
  2. maxAbsVal(List vals)
  3. maxIndex( List list)
  4. maxIndex(List list)
  5. maxInnerSize(List> listOfLists)
  6. maxLength(List patterns)
  7. maxLength(List list)
  8. maxLength(List strings)
  9. maxList(Iterable iterable)