Java Array Max Value arrayMaximum(int[] array)

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

Description

array Maximum

License

Open Source License

Parameter

Parameter Description
array of ints

Exception

Parameter Description
NoSuchElementException if you give it an empty or null array

Return

An integer which is equal to the largest element in the array

Declaration

public static int arrayMaximum(int[] array) 

Method Source Code

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

import java.util.*;

public class Main {
    /**/*  w ww  .  j  a  va 2s  .  c  o  m*/
     *
     * @param array of ints
     * @return An integer which is equal to the largest element in the array
     * @throws NoSuchElementException if you give it an empty or null array
     */
    public static int arrayMaximum(int[] array) {
        if ((array == null) || (array.length == 0)) {
            throw new NoSuchElementException();
        }
        int q = array[0];
        for (int i = 1; i < array.length; i++) {
            if (array[i] > q) {
                q = array[i];
            }
        }
        return q;
    }
}

Related

  1. arrayMax(double maxVal, double[] vals)
  2. arrayMax(double[] arr)
  3. arrayMax(double[] x)
  4. arrayMax(final int[] array)
  5. arrayMax(int[] property)
  6. findMax(double newNumber, double currentMax)
  7. findMax(double[] arr)
  8. findMax(double[] u, int startU, int length)
  9. findMax(double[] u, int startU, int length)