Java Find Max, Min Value in Array

Java code to get Maximum value and Minimum value in a Array

There is no predefined function in java to get Max and Min numbers in a Array. In the below code getMinValue function will give you the minimum value in the given array and getMaxValue function will give you themaximum value in the given array.

public static int getMaxValue(int[] numbers){
int maxValue = numbers[0];
for(int i=1;i < numbers.length;i++){
if(numbers[i] > maxValue){
maxValue = numbers[i];
return maxValue;

public static int getMinValue(int[] numbers){
int minValue = numbers[0];
for(int i=1;i<numbers.length;i++){
if(numbers[i] < minValue){
minValue = numbers[i];
return minValue;

Related Topic Array Search in Java
Java String Replace Regex
JSTL tag Choose When Example Code
Java Find Average Value in Array
Where Can I Find Out the Newly Created Android Projects 2011   Privacy Policy  Terms of Service  Feedback