/** * This program finds displays the minimum element of a hard-coded array * @author Eric Heim */ public class MethodJavaDoc { /** * The main method that will be executed upon running of the program * @param args Array of command-line arguments */ public static void main(String[] args) { //Array of numbers whose minimum will be found int[] numbers = {75, 65, 24, 11, 45, 32, 22, 3, 54, 5}; //Display the minimum number in the array by calling the //minimum method System.out.println("The minimum number in the array is " + minimum(numbers)); } /** * Returns the minimum element of the array that is passed as an * argument * @param minArray Array whose minimum element will be found * @return The minimum element in the array */ public static int minimum(int [] minArray) { int champion; //If the array is empty, then just return the smallest value //possible if(minArray.length == 0) { champion = Integer.MIN_VALUE; } else { //initialize the smallest element to the first element champion = minArray[0]; //Loop through the array and if the current element is smaller //then the smallest element seen so far, replace the champion //with the new smallest element seen so far for(int i = 1; i < minArray.length; i++) { if(minArray[i] < champion) { champion = minArray[i]; } } } //returns the smallest element in the array return champion; } }