Java Array Max Value max(byte[] values)

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

Description

Get the maximum value in an array subset

License

Open Source License

Parameter

Parameter Description
values the array to search

Return

the minimum value found in the array subset specified

Declaration

public static final byte max(byte[] values) 

Method Source Code

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

public class Main {
    /** Get the maximum value in an array subset
     * @param values the array to search
     * @return the minimum value found in the array subset specified
     *///from w  ww  .ja  v a  2s. c  o m
    public static final byte max(byte[] values) {
        return max(values, 0, values.length);
    }

    /** Get the maximum value in an array subset
     * @param values the array to search
     * @param offset the offset into the array at which to start searching
     * @param length the number of values to search
     * @return the minimum value found in the array subset specified
     */
    public static final byte max(byte[] values, int offset, int length) {
        byte max = Byte.MIN_VALUE;
        int offLen = offset + length;
        for (int i = offset; i < offLen; i++) {
            if (max < values[i]) {
                max = values[i];
            }
        }
        return max;
    }

    /** Get the maximum value in an array subset
     * @param values the array to search
     * @return the minimum value found in the array subset specified
     */
    public static final short max(short[] values) {
        return max(values, 0, values.length);
    }

    /** Get the maximum value in an array subset
     * @param values the array to search
     * @param offset the offset into the array at which to start searching
     * @param length the number of values to search
     * @return the minimum value found in the array subset specified
     */
    public static final short max(short[] values, int offset, int length) {
        short max = Short.MIN_VALUE;
        int offLen = offset + length;
        for (int i = offset; i < offLen; i++) {
            if (max < values[i]) {
                max = values[i];
            }
        }
        return max;
    }

    /** Get the maximum value in an array subset
     * @param values the array to search
     * @return the minimum value found in the array subset specified
     */
    public static final char max(char[] values) {
        return max(values, 0, values.length);
    }

    /** Get the maximum value in an array subset
     * @param values the array to search
     * @param offset the offset into the array at which to start searching
     * @param length the number of values to search
     * @return the minimum value found in the array subset specified
     */
    public static final char max(char[] values, int offset, int length) {
        char max = Character.MIN_VALUE;
        int offLen = offset + length;
        for (int i = offset; i < offLen; i++) {
            if (max < values[i]) {
                max = values[i];
            }
        }
        return max;
    }

    /** Get the maximum value in an array subset
     * @param values the array to search
     * @return the minimum value found in the array subset specified
     */
    public static final int max(int[] values) {
        return max(values, 0, values.length);
    }

    /** Get the maximum value in an array subset
     * @param values the array to search
     * @param offset the offset into the array at which to start searching
     * @param length the number of values to search
     * @return the minimum value found in the array subset specified
     */
    public static final int max(int[] values, int offset, int length) {
        int max = Integer.MIN_VALUE;
        int offLen = offset + length;
        for (int i = offset; i < offLen; i++) {
            if (max < values[i]) {
                max = values[i];
            }
        }
        return max;
    }

    /** Get the maximum value in an array subset
     * @param values the array to search
     * @return the minimum value found in the array subset specified
     */
    public static final long max(long[] values) {
        return max(values, 0, values.length);
    }

    /** Get the maximum value in an array subset
     * @param values the array to search
     * @param offset the offset into the array at which to start searching
     * @param length the number of values to search
     * @return the minimum value found in the array subset specified
     */
    public static final long max(long[] values, int offset, int length) {
        long max = Long.MIN_VALUE;
        int offLen = offset + length;
        for (int i = offset; i < offLen; i++) {
            if (max < values[i]) {
                max = values[i];
            }
        }
        return max;
    }

    /** Get the maximum value in an array subset
     * @param values the array to search
     * @return the minimum value found in the array subset specified
     */
    public static final float max(float[] values) {
        return max(values, 0, values.length);
    }

    /** Get the maximum value in an array subset
     * @param values the array to search
     * @param offset the offset into the array at which to start searching
     * @param length the number of values to search
     * @return the minimum value found in the array subset specified
     */
    public static final float max(float[] values, int offset, int length) {
        float max = Float.MIN_VALUE;
        int offLen = offset + length;
        for (int i = offset; i < offLen; i++) {
            if (max < values[i]) {
                max = values[i];
            }
        }
        return max;
    }

    /** Get the maximum value in an array subset
     * @param values the array to search
     * @return the minimum value found in the array subset specified
     */
    public static final double max(double[] values) {
        return max(values, 0, values.length);
    }

    /** Get the maximum value in an array subset
     * @param values the array to search
     * @param offset the offset into the array at which to start searching
     * @param length the number of values to search
     * @return the minimum value found in the array subset specified
     */
    public static final double max(double[] values, int offset, int length) {
        double max = Double.MIN_VALUE;
        int offLen = offset + length;
        for (int i = offset; i < offLen; i++) {
            if (max < values[i]) {
                max = values[i];
            }
        }
        return max;
    }
}

Related

  1. max(boolean useInt, int... value)
  2. max(byte[] arr)
  3. max(byte[] array)
  4. max(byte[] array)
  5. max(byte[] lArray, byte[] rArray)
  6. max(D... comparables)
  7. max(double array[], int start, int length)
  8. max(double values[])
  9. max(double values[], int size)