/********************************************************************* * Author: Eric Heim * Date Created: 6/16/2011 * Course: CS0007 * Description: Shows how to find the maximum element in an array *********************************************************************/ public class ArrayMax { public static void main(String[] args) { int[] myArray = {49, 99, 23, 54, 7, 16, 82}; int max = myArray[0]; for(int i = 1; i < myArray.length; i++){ if(myArray[i] > max) { max = myArray[i]; } } System.out.println("The maximum element in the array is: " + max); } }