find minimum and maximum values in a java array

Solutions on MaxInterview for find minimum and maximum values in a java array by the best coders in the world

showing results for - "find minimum and maximum values in a java array"
Malloy
07 May 2019
1// Java program to find maximum and minimum number without using array
2import java.util.Scanner;
3public class MaximumMinimumWithoutArray
4{
5   public static void main(String[] args)
6   {
7      Scanner sc = new Scanner(System.in);
8      System.out.println("Please enter total number: ");
9      int numbers = sc.nextInt();
10      int maximum = Integer.MIN_VALUE;
11      int minimum = Integer.MAX_VALUE;
12      System.out.println("Please enter " + numbers + " numbers.");
13      for(int a = 0; a < numbers; a++)
14      {
15         int current = sc.nextInt();
16         if(current > maximum)
17         {
18            maximum = current;
19         }
20         if(current < minimum)
21         {
22            minimum = current;
23         }
24      }
25      System.out.println("largest of " + numbers + " numbers is: " + maximum);
26      System.out.println("smallest of " + numbers + " numbers is: " + minimum);
27      sc.close();
28   }
29}
Emelie
07 Apr 2016
1private static int findMin(int[] array) {
2		int min = array[0];
3		for(int i=1;i<array.length;i++) {
4			if(min > array[i]) {
5				min = array[i];
6			}
7		}
8		return min;
9	}
Alia
10 Apr 2016
1// Find minimum and maximum values in a java array
2public class MaxMinValueInArray
3{
4   public static void main(String[] args) 
5   {
6      int[] arrNumber = new int[]{50, 150, 250, 500, 160, 530};
7      int maximum = maxNumber(arrNumber);
8      System.out.println("Maximum value : " + maximum);
9      // calling min function java
10      int minimum = minNumber(arrNumber);
11      System.out.println("Minimum value : " + minimum);
12   }
13   // java find max in array
14   public static int maxNumber(int[] arr)
15   {
16      int maximumValue = arr[0];
17      for(int a = 1; a < arr.length; a++)
18      {
19         if(arr[a] > maximumValue)
20         {
21            maximumValue = arr[a];
22         }
23      }
24      return maximumValue;
25   }
26   // java min of array
27   public static int minNumber(int[] arr)
28   {
29      int minimumValue = arr[0];
30      // find minimum value in array java
31      for(int a = 1; a < arr.length; a++)
32      {
33         if(arr[a] < minimumValue)
34         {
35            minimumValue = arr[a];
36         }
37      }
38      return minimumValue;
39   }
40}
Camilo
16 Apr 2018
1public class MinimumNumber{
2  public static void main(String[] args){
3    int[] arr=new int[]{2,3,4,1};
4    int min=arr[0];
5    for(int i=0;i<arr.length;i++){
6      if(arr[i]<min){
7        min=arr[i];
8      }
9    }
10    System.out.println("Minimum Number in array:"+min);
11  }
12}
Fynn
09 Nov 2016
1Integer[] num = { 2, 4, 7, 5, 9 };
2        // using Collections.min() to find minimum element
3        // using only 1 line.
4        int min1 = Collections.min(Arrays.asList(num));
5
6        // using Collections.max() to find maximum element
7        // using only 1 line.
8        int max1 = Collections.max(Arrays.asList(num));
9
10        System.out.println(min1); // 2 
11        System.out.println(max1); // 9
queries leading to this page
get min from array javahow to find minimum value in array javajava program to find maximum and minimum number without using arrayfind maximum and minimum number in array javasecond max number in array using javashow to find the maximum value in an array java withoutfind the min value in an array javawrite a java program to print the sum of the maximum and the minimum element in the array in javajava min max arraymin and max numbers in array javahow to find max min of an array in javahow to find lowest and highest value in array javafind max java arraymax and min in array in javajava max and min of an arrayfinding minimum value in array javahow to find the min value in array in javahow to find minimum and maximum value in javahow to find max andd min in javafind minimum and maximum values in a java arrayget minimum value in array javamax min in an array javafind minimum maximum values in a arrayfind max value in array javafinding min and max values in array javafind minimum value in array in javamaximum and minimum of an array using minimum number of comparisons javahow to get the max and min number possible in javajava code to get max value from arrayfind min from array in javamax value in array javajava program to find minimum number in an arrayjava find min in arrayjava array min and maxhow to get the max and min of an array in javahow to find max and min in array in javamaximum and minimum value javahow to check array min value in javafind minimum number in array javaprogram calculate the minimum value in the array in java min and max from array javahow to find the min in an array javafind lowest value in array in javahow to return lowest value of array javajava code for least value of int arrayjava method to min value in arrayfind min and max in array javafind minimum value array javamin element in array in javahow to find the minumum value of a int array javamin value array javawrite a function to find the minimum and maximum value of an array in javafind minimum value without array javamin max of array javamaximum 2fminimum java with arraysfind minimum of array javaget largest value through maximum and minimum javajava find minimum valuemaximum of array java max valueminimum and maximum in array javaminimum of array javafind min in an array javainbuilt function in java to find min of arrayarray max function in javafind maximum and minimum in array in javaarray string get max value javamethod to get max value of an array in javafind the minum of n numbers in javaminimum value algorithmn in array javafind minimum and maximum value in arrayjava how to get the max value from an arrayfind max number from array in javamin in java arraymax min value array javahow to get minimum value in a arraymin of an array javaget min value from array javareturning the minimum number in an array javafind the maximum and minimum value program in javafind min and max in array in javajava array max elementfind the max value of something in an array in javafind min and max values in javamax and min element in array in javamin in array javaget minimum of array javasecond max from array in javafind min value in the arrayjava minimum and maximum values in arrayjava find the minimum value in an arrayhow to find maximum in array using function in javajava find max score in arraymin function in java arrayhow to get the max value in an arrayjava min of arrayfind maximum and minimum element in an array in javafind the minimum and maximum in an arraymaximum array in javafind minimum and maximum element in an array javafind the maximum value in array javaminimum value in a array javafind the minimum value in an array javamin and max in java arraywrite a java program to find the maximum and minimum value of an array how to calculate max and min in javamin and max in array javaminimum of an array in javajava largest value arrayhow to find min and max in array javafind maximum and second maximum in array javahow to find maximum and minimum value in array in javahow to find the highest and lowest number in an array using javafind min and max in array java scajava min value in arrayset integer array with minimum and maximum valuebest way to find minimum values in javahow to find the maximum value in an array java without methodmin and max value in array java using for eachget max value from array javahow to get minimum value in array javaprint max value in array javafind maximum and minimum values of a list javahow to get minimum from an array javajava how to get highest value between multiple arraysmax value in an array in javahow to find minimum of an array in javaminimum in array javaminimum value array javamax function in java arrayjava get minimum value in arraywrite a java program to find maximum and minimum element in an array java find min value in arrayfind maximum and minimum number in array in javaprogram that gives the minimum and maximum value of an array element in javaminimum value in java arrayfind min and max in array javafind maximum and minimum from three number in java by using methodjava array min max using inbuilt functionsmax of array in javahow to set a minimum and maximum value in javafind the max or min value in an array javamin element in array javajava min from arrayarray min value javamethod to find min element in array in javahow to find the minimum of an integer array in javamax value array javaminimum value in array javahow to find the max value in an array in javamax and min of array in java using inbuilt functionfunction to find max element in array in javahow to get the max value in an array in javafinding the minimum value of an array in javahow to calculate minimum of int array in javafind minimum and maximum element in an array in javacalculate min javaget the minimum value in an array javahow to find minimum number in array in javafind minimum and maximum element in an array in java gfg solutionjava program to find min value in array for specific index built in functionminimum of array in javajava program to find min value in array built in functionto find minimum index in an array javahow to calculate the minimum and maximum value in the arrayhow to calculate minimum using java program using arrayhow to find min number in array javawrite a java program to find the maximum and minimum value of an arrayfind min in int array javajava program to find maximum number without using arrayminimum element in array javafind max and min value in array javafind the max scrore form array in javamaximum and minimum in an array in javahow to get the min of an array in javajava max min fucntion for arrayhow to find minimum value in array of string in javaminimum in an array javaprogram to find maximum number in array in javaminimum and maximum in javajava find out max and min in arrayfinding min and max from given number in javamin max in array javamaximum and minimum of an array using minimum numberhow to find the maximum and minimum in an array in javajava find max and min in arrayjava program to find maximum and minimum number in an arrayhow to find the minimum of an array javamax and min array number in javafind minimum and maximum element in an array in java with user inputfind max and min number in array in javaget minimum number from array javajava array to find max and minfind minimum and maximum number in an arrayfind min value in array javafind max and min number in a given array in javamaximum and minimum in javafinding minimum of array in java functionmin max in array in java with methodjava to find the minimum and maximum from a given arrayhow to find the max value of an array in javamin and max in an array javafind minimum maximum valuesarray find minimum value javafinding minimum element in an array javajava 8 min value in array 3a write a program to accept 20 integer elements and display the maximum and minimum element from the array in javajava program to find maximum and minimum number using arrayhow to get minimum value in a array javamaximum minimum average number java arrayminimum number from array in javaarray find max in javahow to get the minimum of an int array in javajava minimum integer in arrayjava find max value in arrayfind the min and max in an array javamaxmin of a array in javafind max array javahow to find the min of an array in javahow to find minimum and maximum in javawrite a program in java to find the maximum and minimum element in an array getting the minimum value in an array in javaminimum in array java using methodsmax and min number array in javasearch number between min and max javamin value of an array java 3a write a program to accept 20 integers elements and display the maximum and minimum element from the array in javamax val array javafind min and max in array java of longarrays max javahow to find max value in array java methodminimum and maximum in arraymethod to get minimum value of an array in javagettin the minimum value in an array in javahow to find the minimum element in an array in javafind the minimum and maximum element in an array javafind out the min from an int array in java min functionjava arrays find minwrite a program to find maximum and minimum value in a array how to find minimum and maximum values in an array in java shortutfind min value in int array in javajava find maximum value in arrayto find and print the maximum value stored in an array in javaget max value in array javafind max single didgit number from array in javahow to calculate a min number in a array in javajava array find max valuejava java when find min in array it returns only 0input some values into an array and find the minimum value in it in javahow to find maximum and minimum value of a arrayhow to find the minimum of an array in javamax and min of array in javamax element in array javahow to get the lowest value in an array javafinding minimum in an array javafind the minimum value of an array javamin array javahow to find minimum number in array javafinding the min of an arrray javajava return minimum value in arraymax min max min array javahow to find minimum value in array in java inbuilt functionhow to find min and max javafind max and min of array in javamethod for finding min in array javamin and max of array javafind max in array javamaximum and minimum in an arrayfind maximum mininum in java arrayjava how to get a maximum value in arrayjava program to find min elements in the arraymax element of an array in javaminimum from array javahow to take the min of an array in javamin number array in javamin array number in javaget maximum and 2nd maximum number from array javafind min number in array using math in javaminimum number java arrayfind min of array javahow to find the max and min of an array in javajava min in arrayhow to find the minimum and maximum number of a arraymin value in array javafind maximum value in array javato find max of n numbers of array javafind minimum number in array in javagetting minimum and max values from ana array javajava miniumum of arrayjava function that returns max value in arrayfinding max number in array javajava maximum arrayusing math min in an array javamax and min of array javamin of array in javajava find minimum value in arraywrite a program to find the maximum and minimum value of an arrayfind min no in array javaget min value of array javajava get min of arraymax value of an array javajava cant find min in arraymin of array javaget minimum element in array javajava code to find the max in and arrayhow to get the max values if i know the minimum in javamaximum and minimum number in array javahow to find minimum value in an array in javafinding min and max in javajava get max of arrayjava program minimum and maximum values in arrayjava min of arrayhow to find minimum and maximum values in an array in javajava array maximum and minimumadd in min and max of an array javajava logic to find min number in arrayfind max integer in array javahow to find maximum and minimum value in javahow to find the minimum value of an arraymin and max element in array in javamin max array javajava program to find maximum number in an arraymaximum and minimum using 1 method in javaarray min value javafind min number in array in javagetting max and min of array in javafind max number in array javamax and min value of array in javajava max and min valuesget max value of matrix javaget minimum value from array javahow to find minimum value in an array javafind max or min value in an array of primitives using javamin from array javahow to find minimum value in array in javafind min of array with sream javajava find lowest number in arrayhow to find the minimum of a set of numbers in javagetting the max of an array in javafinding max element in array javafind maximum and minimum in array javahow to find minimum in array javaarrays return max value javafinding max and min in array java functionjava find max in arrayjava program to find min elememt in arraymin element of array javawrite a java program to find maximum and minimum element in a array find max of array in javahow to find minimum and maximum value of an arrayinbuilt function find min value from array javajava get min from arrayget the minimum of a array javaminimum value of an array javahow to find the min and max of an array javaget the min in array javajava code to find minimum number in an arrayhow to get the min value of an array in javafind minimum value in array java use function get min value in array javaget max value of array javaget the lowest value from an array javaget lowest value in array javapremitive array max min javafind the minimum number in an array javafind maximum value in array java methodfind min number in array javajava display numbers in order minimum to maximumfind max value from an int array javamax and min in array javamin and max value in array javajava get max value from array built in methodfind the max number in an array javahow to return the minimum value in an array in javafind max and min values in an array of primitives using javaget minimum and maximum values in arrays of different sizes javajava find a min in an arraymin number in array javahow to get min from array in javamin and max array javajava finding max of arrayfind the maximum and minimum element in an array in javahow to check for minimum number in array javahow to find the minimum value of an array in javahow to find lowest and highest value in array of integermaximum minimum element in array javafinding minimum between arrays javafind minimum value array inthow to find the minimum value in an array javamin value of array in javahow to get min and max value from array in javawa java program to find minimum number in an arrayfind min in array javahow to find the minimum number from array in javahow find minimum in javaarray min value java methodhow to find the lowest value in an array javahow to fint lowest value in array javaget maximum value in array javamax min in array javamin of element in an array in javaget the min value in array javamin array in javahow to find min in array javaminimum and maximum value of array in javagetting the maximum value of an array in javaminimum element in an array in javasearch for the max and min value of an arrayget minimum from array javaget maximum value of array javamax function in java for arrayfind the max and min of an array javasjava find the lowest value of an arraymax in array javamin function in java for arrayjava array find minimum valuefind minimum of array in javamaximum and minimum of an array using minimum number of comparisons using javajava program to find the maximum and minimum value of an array how to find the minimum value in an array in javaarray find min in javahow to display minimum and maximum number in an arrayjava minimum value in arrayarray min and max in javajava program to find min value in arraymin of an array in java how to find min and max value in array in javahow to find max value from array in javafind minimum value in array javahow to display minimum value of an array javahow to find max to minin array javamax and min in java arrayhow can i find the maximum minimum from a array 3ffinding the highest value in a matrix javahow to calculate max and min in java 27how can i find the maximum minimum from an array 3fhow to get the minimum of an arrayarrays minimum javajava array find max and minjava logic to get min of arrayjava method to find max value in arrayminimum and maximum element in an array in javafinding minimum element in array javaget max value array javahow to find out the min and max in an array in javahow to get the maximum and minimum values of an array in javajava array max valuemaximum and minimum in array javadefined function for max in java using arraysjava array minimum valuefind minimum in array javajava find minimum of an arrayhow to find minimum in int arrayget min value of int array javaget min of array javafind minimum and maximum values in a java array