Here you can find the source of max(int[] elements)
Parameter | Description |
---|---|
elements | a parameter |
public static int max(int[] elements)
//package com.java2s; /*/* w w w .j ava 2s.c o m*/ * This file is part of the Feature Model Synthesis project (FMSynth). * * Copyright (C) 2010 Steven She <shshe@gsd.uwaterloo.ca> * * FMSynth is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the * Free Software Foundation, either version 3 of the License, or (at your * option) any later version. * * FMSynth 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with FMSynth. (See files COPYING and COPYING.LESSER.) If not, see * <http://www.gnu.org/licenses/>. */ public class Main { /** * returns Integer.MIN_VALUE for an empty or null array * * @param elements */ public static int max(int[] elements) { int result = Integer.MIN_VALUE; if (elements != null) for (int i : elements) result = (result >= i ? result : i); return result; } /** * returns Integer.MIN_VALUE for an empty or null array * * @param elements */ public static int max(Iterable<Integer> elements) { int result = Integer.MIN_VALUE; if (elements != null) for (int i : elements) result = (result >= i ? result : i); return result; } }