Java Integer max() MethodThe max() is a method of Integer class under Java.lang package. This method numerically returns the maximum value between the two method arguments specified by a user. This method can be overloaded and it takes the arguments in int, double, float and long. This method is specified by the Math Class. Note: If a positive and a negative number is passed as argument, it generated a positive result. And if, both the parameters passed as a negative number, it generates result with the lower magnitude.Syntax:Following is the declaration of max() method: Parameter:
Returns:The max() method returns the greater value between the two method arguments specified by a user. Exceptions:NA Compatibility Version:Java 1.5 and above Example 1Output: Math.max(5485,3242)=5485 Example 2Output: Enter the Two Numeric value: 45 77 Larger value of Math.max(45,77) = 77 Example 3Output: Result: -23 Example 4Output: Result: 23 Next TopicJava-integer-min-method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India