Java Array Max Value max(int[] array)

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

Description

max

License

Apache License

Declaration

public static int max(int[] array) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.ArrayList;

public class Main {
    public static int max(int[] array) {
        int max = -Integer.MAX_VALUE;
        for (int a : array) {
            if (a > max) {
                max = a;//from   ww w. ja v  a2s  . c o m
            }
        }
        return max;
    }

    public static double max(double[] array) {
        double max = -Double.MAX_VALUE;
        for (double a : array) {
            if (a > max) {
                max = a;
            }
        }
        return max;
    }

    public static double max(ArrayList<Double> array) {
        double max = -Double.MAX_VALUE;
        for (double a : array) {
            if (a > max) {
                max = a;
            }
        }
        return max;
    }
}

Related

  1. max(int[] arr, int count)
  2. max(int[] array)
  3. max(int[] array)
  4. max(int[] array)
  5. max(int[] array)
  6. max(int[] as)
  7. max(int[] data)
  8. max(int[] elements)
  9. max(int[] ids)