Write a program to find the maximum element in an array?
Maximum element in an array.
package Array; /** * * @author stratos */ public class MaxElement { public static void main(String[] args) { int[] array = {5, 8, 4, 9, 10, 15}; int max = array[0]; for (int i = 0; i < array.length; i++) { if (array[i] > max) { max = array[i]; } } System.out.println("" + max); } }
15
post a comment