0

won't print the highest int?

I added a 100 to the math.max example and it won't print the 100 why? how I wrote it int m= Math.max =(10, 20, 100);

11th Oct 2016, 12:52 AM
WHITEHOOD
3 Respuestas
+ 2
As others said: the Max() method just takes two numbers , not three. But you can do this to compare 3 numbers: Math.max(Math.max(a,b),c)
13th Oct 2016, 2:49 PM
AmirHosein Mansoori
AmirHosein Mansoori - avatar
0
java.lang.Math.max(int a, int b) returns the greater of two int values.  It only compares two values, not three.
11th Oct 2016, 2:19 AM
Sumita Das
Sumita Das - avatar
0
The compiler will give an error if you have three inputs for the Math.max method. It's a good idea to refer to Java docs online when you are using a method. Math.max method compares only two inputs. If you want to compare three you can do so with two successive calls to the max method.
13th Oct 2016, 2:21 PM
Shaik Shahnaz