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);
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)
0
java.lang.Math.max(int a, int b) returns the greater of two int values.
It only compares two values, not three.
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.