Here you can find the source of min(int[] arr)
Parameter | Description |
---|---|
arr | An array of integers |
public static int min(int[] arr)
//package com.java2s; //License from project: Apache License public class Main { /**// w w w. j a va 2 s . co m * Find min value in an array of integers. * * @param arr An array of integers * @return Min value */ public static int min(int[] arr) { if (arr == null || arr.length == 0) { throw new IllegalArgumentException("Array cannot be null or empty"); } int minVal = Integer.MAX_VALUE; for (int i : arr) { if (i < minVal) { minVal = i; } } return minVal; } }