+ 2

Math. max() method

Can we give only two parameters in Math. max();?

2nd Jan 2018, 12:38 PM
Shalini Jha
Shalini Jha - avatar
8 Answers
+ 4
Hey, you could alternatively just add all the numbers to an array list of Integer and use the Collections.max() method to extract the largest number. This saves time and gets rid of using multiple 'nested Math.max ()'
2nd Jan 2018, 1:15 PM
Tarantino
Tarantino - avatar
+ 4
Glad I could help!
2nd Jan 2018, 1:25 PM
Tarantino
Tarantino - avatar
+ 3
Yeah it is a static method which is part of the Collections class which is part of the util package so you will have to import java.util.Collections;
2nd Jan 2018, 1:18 PM
Tarantino
Tarantino - avatar
+ 3
I can indeed : min, sort, frequency etc but the best thing to do is to look at the Collections class java docs from oracle and see all of the many methods that are part of it.
2nd Jan 2018, 1:21 PM
Tarantino
Tarantino - avatar
+ 2
I got it.... its maxim range is 2.If we want to compare more numbers we have to use nested Math. max();
2nd Jan 2018, 12:46 PM
Shalini Jha
Shalini Jha - avatar
+ 1
Is Collections. max() an predefined method?
2nd Jan 2018, 1:17 PM
Shalini Jha
Shalini Jha - avatar
+ 1
Can you name some other methods of this Package?
2nd Jan 2018, 1:20 PM
Shalini Jha
Shalini Jha - avatar
+ 1
Thanks @Minato....
2nd Jan 2018, 1:23 PM
Shalini Jha
Shalini Jha - avatar