find largest value of all elemnts in array code example
Example: find the maximum number from an int Array
---without sort method---
public static int maxValue( int[] n ) {
int max = Integer.MIN_VALUE;
for(int each: n)
if(each > max)
max = each;
return max;
---with sort method---
public static int maxValue( int[] n ) {
Arrays.sort( n );
return n [ n.lenth-1 ];
}