maximum from array code example
Example 1: Find the maximum number of an array js
function getMaxOfArray(numArray) {
return Math.max.apply(null, numArray);
}
Example 2: maximum number from 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 ];
}