About 1,480,000 results
Open links in new tab
  1. java - How do I get the max and min values from a set of …

    Here's a possible solution: public static void main(String [] args) { int min = Integer.MAX_VALUE; int max = Integer.MIN_VALUE; Scanner s = new Scanner(System.in); while (true) { System.out.print("Enter a Value: "); int val = s.nextInt(); if (val == 0) { break; if (val < min) { min = val; if (val > max) { max = val;

  2. java - Find a maximum and minimum value using for loop - Stack Overflow

    Apr 11, 2018 · I am trying to take 10 integers from the user's input and find the minimum and maximum using for loop. But my final print statement just prints the list of numbers entered. I'm lost. Scanner scan=new Scanner(System.in); double a = 0; double max = 0; double min = 0; System.out.print("Enter ten floating points: \n"); for(a=0; a <10; a++) {

  3. Min and Max in a List in Java - GeeksforGeeks

    Jan 11, 2023 · Given an unsorted list of integers, find maximum and minimum values in it. Output : max = 20, min = 1. Input : list = [10, 400, 3, 2, 1, -1] Output : max = 400, min = -1. Sorting. This is least efficient approach but will get the work done.

  4. Finding the minimum and maximum values in a user inputed array (Java ...

    Apr 5, 2016 · if (numbers[count-1] < min) { min = numbers[count-1]; } condition inside the while loop. This will find the minimum in the same loop that reads the input. Of course, if you do that, you don't need to store the elements in an array at all, so you can further simplify the code.

  5. Program to find the minimum (or maximum) element of an array

    Apr 10, 2025 · Given an array A[] of N integers and two integers X and Y (X ≤ Y), the task is to find the maximum possible value of the minimum element in an array A[] of N integers by adding X to one element and subtracting Y from another element any number of times, where X ≤ Y. Examples: Input: N= 3, A[] = {1,

  6. How to calculate Maximum and minimum in Java? Beginner …

    That's all about how to calculate maximum and minimum of two numbers in Java. In this tutorial, you have learned how to get input from the user, how to use a relational operator to compare two numbers, and how to use java.lang.Math class to perform common mathematical operations e.g. finding maximum and minimum of two numbers.

  7. Java program to find maximum and minimum values of a list …

    Steps to find maximum and minimum values in a list : Get the total count of the numbers from the user. Using a loop, get the inputs of the numbers. Add these numbers to a list. Now, get the value of maximum and minimum of the range. We need to find the maximum and minimum of all numbers within this range.

  8. Java 8 Program to Find the Maximum Number and Minimum ... - Java

    This blog post will demonstrate how to use Java 8 Streams to find the maximum and minimum numbers in a list. Streams in Java 8 provide a high-level abstraction for processing sequences of elements, including a rich set of operations to perform bulk operations on collections, such as finding the minimum or maximum value.

  9. Finding Max/Min of a List or Collection - Baeldung

    Apr 4, 2025 · To determine the minimum or maximum value in an ArrayList, we can either use the method we saw earlier or the min() and max() methods of the Java Collections class. Those methods return the minimum and maximum element of a given collection, respectively.

  10. java - How to write a program to get minimum, maximum and …

    Jan 12, 2014 · Write a program using a loop that takes 10 values from a user representing exam grades (between 0 and 100) from the keyboard and outputs the minimum value, maximum value and average value of all the values entered. Your program should not accept values less than 0 or greater than 100.

  11. Some results have been removed
Refresh