0

java

Have there any function in Java which can show us maximum and minimum of integer variables which we Scannered ? (Variables more than two ,so I can not use Math.max or Math.min)

9th Dec 2019, 7:36 PM
Nozimbekovich
Nozimbekovich - avatar
2 RĂ©ponses
+ 2
If the values are in an array or list, then you can use Collections.max() and Collections.min() Also there are max() and min() methods on IntStream https://www.google.com/amp/s/www.geeksforgeeks.org/collections-max-method-in-java-with-examples/amp/ https://www.google.com/amp/s/www.geeksforgeeks.org/intstream-max-in-java-with-examples/amp/
9th Dec 2019, 7:45 PM
Tibor Santa
Tibor Santa - avatar
+ 1
you can have Math.max inside a Math.max. e.g int a = 30; int b = 40; int c = 50; int d = 60; System.out.println(Math.max(Math.max(a, b), c)); System.out.println(Math.max(Math.max(a, b), Math.max(c, d)));
9th Dec 2019, 8:28 PM
rodwynnejones
rodwynnejones - avatar