Returns the least value present in array. @param array a nonempty array of long values @return the value present in array that is less than or equal to every other value in the array @throws IllegalArgumentException if array is empty
(long... array)
| 211 | |
| 212 | |
| 213 | public static long min(long... array) { |
| 214 | checkArgument(array.length > 0); |
| 215 | long min = array[0]; |
| 216 | for (int i = 1; i < array.length; i++) { |
| 217 | if (array[i] < min) { |
| 218 | min = array[i]; |
| 219 | } |
| 220 | } |
| 221 | return min; |
| 222 | } |
| 223 | |
| 224 | /** |
| 225 | * Returns the greatest value present in {@code array}. |