Java Array Max Value max(int value1, int value2, int... values)

Here you can find the source of max(int value1, int value2, int... values)

Description

max

License

Open Source License

Declaration

public static int max(int value1, int value2, int... values) 

Method Source Code

//package com.java2s;
/*//www .  ja va  2 s. com
 * This file is part of the L2J Mobius project.
 * 
 * This program 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.
 * 
 * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    public static int max(int value1, int value2, int... values) {
        int max = Math.max(value1, value2);
        for (int value : values) {
            if (max < value) {
                max = value;
            }
        }
        return max;
    }

    public static long max(long value1, long value2, long... values) {
        long max = Math.max(value1, value2);
        for (long value : values) {
            if (max < value) {
                max = value;
            }
        }
        return max;
    }

    public static float max(float value1, float value2, float... values) {
        float max = Math.max(value1, value2);
        for (float value : values) {
            if (max < value) {
                max = value;
            }
        }
        return max;
    }

    public static double max(double value1, double value2, double... values) {
        double max = Math.max(value1, value2);
        for (double value : values) {
            if (max < value) {
                max = value;
            }
        }
        return max;
    }
}

Related

  1. max(float[] in, int[] idx)
  2. max(float[] position, int x)
  3. max(float[] t)
  4. max(float[] v1, float[] v2)
  5. max(int array[])
  6. max(int... _is)
  7. max(int... args)
  8. max(int... array)
  9. max(int... list)