Answers for "to find and print the maximum value stored in an array in java"

0

find min in array java

private static int findMin(int[] array) {
		int min = array[0];
		for(int i=1;i<array.length;i++) {
			if(min > array[i]) {
				min = array[i];
			}
		}
		return min;
	}
Posted by: Guest on May-10-2020
1

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 ];

}
Posted by: Guest on November-30-2020

Code answers related to "to find and print the maximum value stored in an array in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language