Java Array Max Value max(byte[] array)

Here you can find the source of max(byte[] array)

Description

max

License

Open Source License

Declaration

public final static byte max(byte[] array) 

Method Source Code

//package com.java2s;

public class Main {
    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]);
        }//from   ww w.j  a va  2 s  .com
        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. findMaxValue(int[] array)
  2. findMaxValueIndex(double[] d)
  3. max(boolean useInt, int... value)
  4. max(byte[] arr)
  5. max(byte[] array)
  6. max(byte[] lArray, byte[] rArray)
  7. max(byte[] values)
  8. max(D... comparables)
  9. max(double array[], int start, int length)