java program to find maximum and minimum number without using array

Solutions on MaxInterview for java program to find maximum and minimum number without using array by the best coders in the world

showing results for - "java program to find maximum and minimum number without using array"
Selene
12 Jan 2018
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}
Nola
10 Jun 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}
Lisa
23 Apr 2019
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
how to find minimum number in array in javahow to find max value from array in javahow to find minimum and maximum values in an array in javahow to check for minimum number in array javahow to find the max value of an array in javajava get max of arraymaximum and minimum in an array in javaget minimum value from array javahow to find minimum value in array javaminimum and maximum in javafind maximum and minimum from three number in java by using methodjava program to find maximum number in an arrayhow to find maximum in array using function in javamaximum and minimum of an array using minimum numberjava find max score in arrayprogram calculate the minimum value in the array in java how to find the minimum of an integer array in javamaximum minimum element in array javawrite a function to find the minimum and maximum value of an array in javafind min and max in array java of longfind max number from array in javafind minimum of array in javajava array max elementgetting the minimum value in an array in javajava to find the minimum and maximum from a given arrayhow to get minimum from an array javamax value in an array in javafind max java arrayhow to find the minimum value of an array in javahow to find max min of an array in javahow to find minimum in array javamax min max min array javafind minimum of array javahow to find the max and min of an array in javafind the minimum and maximum element in an array javahow to find the minimum value in an array javafinding min and max values in array javafind the maximum and minimum value program in javaget minimum and maximum values in arrays of different sizes javahow to find the maximum and minimum in an array in javamaximum and minimum in javajava find max in arrayfind the maximum and minimum element in an array in javaminimum value in java arrayjava array find max and minfind maximum and minimum in array javafind minimum and maximum values in a java arraymax in array javagettin the minimum value in an array in javamaximum and minimum number in array javafind the minimum number in an array javafind maximum and minimum values of a list javamax of array in javajava find max value in arraymax element in array javajava program to find maximum number without using arraymaximum 2fminimum java with arraysget minimum from array javaarrays max javamax and min number array in javafinding max number in array javafind minimum and maximum number in an arrayfind max array javamaximum and minimum of an array using minimum number of comparisons using javafind minimum maximum valuesmin and max of array javamin and max element in array in javamaximum array in javajava get minimum value in arrayhow to find minimum and maximum in javafind minimum in array javawrite a java program to find the maximum and minimum value of an array max and min in array javafind minimum and maximum element in an array in java gfg solutionminimum and maximum in arrayhow to find max to minin array javahow to find minimum value in an array in javajava max min fucntion for arraypremitive array max min javafinding minimum value in array javafinding the minimum value of an array in javaprogram to find maximum number in array in javasecond max number in array using javasfind the max number in an array javafinding minimum element in array javafind minimum value in array javajava program to find the maximum and minimum value of an array how to find min and max value in array in javahow to calculate minimum of int array in javahow to find minimum value in array in javareturning the minimum number in an array javahow can i find the maximum minimum from an array 3fmax function in java arrayget the minimum of a array javafind the maximum value in array javahow to find minimum value in an array javahow to calculate the minimum and maximum value in the arraymax min in an array javaarray find max in javaminimum value in array javaget minimum number from array javafind minimum maximum values in a arrayset integer array with minimum and maximum valuewrite a java program to find the maximum and minimum value of an arrayarray max function in javahow to find the minimum element in an array in javahow to find the maximum value in an array java withouthow to find the max value in an array in javafind maximum and minimum element in an array in javamaximum and minimum value javadefined function for max in java using arraysfinding minimum element in an array javahow to find minimum and maximum value of an arrayjava maximum arrayfind max value in array javafind the max scrore form array in javamax and min array number in javahow to set a minimum and maximum value in javaminimum number from array in javajava minimum and maximum values in arrayjava array find max valueget max value from array javafind max or min value in an array of primitives using javaget maximum value in array javajava minimum value in arrayminimum and maximum element in an array in javafind minimum and maximum value in arrayjava array minimum valuemaximum and minimum of an array using minimum number of comparisons javajava code to find the max in and arrayhow to find minimum number in array javafind maximum and second maximum in array javajava program to find maximum and minimum number in an arraywrite a program to find maximum and minimum value in a array java return minimum value in arrayfind min and max in array javahow to find minimum and maximum value in javahow to find the minimum and maximum number of a arrayfind max and min number in a given array in javahow to find the maximum value in an array java without methodfind max single didgit number from array in javaminimum number java arraymin and max array javamax element of an array in javafind min and max in array in javajava program to find maximum and minimum number without using arraymax value in array javahow to find minimum of an array in javaget largest value through maximum and minimum javahow to find the minimum number from array in javahow to find maximum and minimum value of a arrayjava program to find minimum number in an arrayhow to find minimum value in array in java inbuilt functionhow to find minimum and maximum values in an array in java shortutfind the minimum and maximum in an arraymax and min in array in javaget maximum and 2nd maximum number from array javafind minimum and maximum element in an array in javahow to find maximum and minimum value in javafind the minimum value in an array javahow to find the minimum of an array javaminimum and maximum value of array in javafind minimum value without array javagetting minimum and max values from ana array javamax and min element in array in javahow can i find the maximum minimum from a array 3fmin max array javafind the max or min value in an array javafind the max and min of an array javasfind max and min value in array javahow to find maximum and minimum value in array in javamaximum of array java max valuefind minimum and maximum element in an array javamax value of an array javamaximum minimum average number java arrayfind max number in array javafind max and min of array in javajava how to get the max value from an arraymaximum and minimum in an arrayget minimum element in array javasecond max from array in javafind min and max in array java scaminimum value algorithmn in array javajava get max value from array built in methodget max value in array javamaximum and minimum using 1 method in javafind minimum value in array in javafinding max and min in array java functionfinding max element in array javajava find minimum value in arrayfind minimum number in array javawa java program to find minimum number in an arrayjava find max and min in arrayfinding minimum between arrays javafind maximum and minimum in array in javawrite a program to find the maximum and minimum value of an arraymin value of array in javajava find maximum value in arrayinput some values into an array and find the minimum value in it in javamax function in java for arrayjava code to find minimum number in an arrayfunction to find max element in array in javagetting the max of an array in javafind maximum mininum in java arrayarray min and max in javafind max in array javajava program to find maximum and minimum number without using array