Java Array Max Value max(int[] t)

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

Description

Figure out maximum number in array.

License

Open Source License

Parameter

Parameter Description
t All number to compare

Return

Highest number

Declaration

public static int max(int[] t) 

Method Source Code

//package com.java2s;
/*//from   www. j a  v  a  2s .  co m
 * PackJacket - GUI frontend to IzPack to make Java-based installers
 * Copyright (C) 2008 - 2009  Amandeep Grewal, Manodasan Wignarajah
 *
 * PackJacket is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * PackJacket is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with PackJacket.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    /**
     * Figure out maximum number in array.
     * @param t All number to compare
     * @return Highest number
     */
    public static int max(int[] t) {
        // start with the first value
        int maximum = t[0];
        for (int i = 1; i < t.length; i++)
            if (t[i] > maximum)
                // new maximum
                maximum = t[i];
        return maximum;
    }
}

Related

  1. max(int[] elements)
  2. max(int[] ids)
  3. max(int[] in, int x1, int x2)
  4. max(int[] list)
  5. max(int[] nums)
  6. max(int[] vals, int max)
  7. max(int[] values)
  8. max(int[] values)
  9. max(int[] values)