Java Array Max Value max_array(byte[] arr)

Here you can find the source of max_array(byte[] arr)

Description

maarray

License

Open Source License

Declaration

public static byte max_array(byte[] arr) 

Method Source Code

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

public class Main {
    public static byte max_array(byte[] arr) {
        if (arr != null && arr.length > 0) {
            byte max = arr[0];
            for (int i = 0; i < arr.length; i++) {
                if (arr[i] > max) {
                    max = arr[i];/* w ww.  j  av a  2s  .  com*/
                }
            }
            return max;
        }
        return Byte.MIN_VALUE;
    }

    public static short max_array(short[] arr) {
        if (arr != null && arr.length > 0) {
            short max = arr[0];
            for (int i = 0; i < arr.length; i++) {
                if (arr[i] > max) {
                    max = arr[i];
                }
            }
            return max;
        }
        return Short.MIN_VALUE;
    }

    public static int max_array(int[] arr) {
        if (arr != null && arr.length > 0) {
            int max = arr[0];
            for (int i = 0; i < arr.length; i++) {
                if (arr[i] > max) {
                    max = arr[i];
                }
            }
            return max;
        }
        return Integer.MIN_VALUE;
    }

    public static long max_array(long[] arr) {
        if (arr != null && arr.length > 0) {
            long max = arr[0];
            for (int i = 0; i < arr.length; i++) {
                if (arr[i] > max) {
                    max = arr[i];
                }
            }
            return max;
        }
        return Long.MIN_VALUE;
    }
}

Related

  1. max(Number[] array)
  2. max(T first, T... others)
  3. max(T... elems)
  4. max(T... values)
  5. max(T[] args)
  6. max_index(int[] v)
  7. max_of_ints(int[] data)
  8. max_val_subsequence(int[] vals)
  9. maxAbs(double[] a, int begin, int end)