Maximum value acquiring: Find the maximum from all the elements of an array.
Realization of ideas:
definition of variables, save the array element on the index 0
iterate, obtaining the array element of each
variable on the traverse to the array of storage elements and compares the index value 0
if the value of the array element is greater than the value of the variable , recorded live in the new variable value of
an array to loop through the end of the saved variable is an array of maximum
// find the maximum public class ArrayDemo3 { public static void main (String [] args) { int [] = {1,2,3,4,5,6,6} ARR; // define an array of storage elements designated int ARR = SUM [0]; // assume that the first element is the maximum value of // for loop through the array of elements, with each cycle the element array index 0 magnitude comparison for ( int I = 0; I <arr.length ; I ++ ) { IF (sum <ARR [I]) { // element in comparison with the sum array, the sum over a large sum assigned to put it as a new comparative value sum = ARR [I]; } } the System.out .println (SUM); // maximum value of the output array } }