Java Float - max() Method
The java.lang.Float.max() method returns the greater of two float values as if by calling Math.max.
Syntax
public static float max(float a, float b)
Parameters
a |
Specify the first operand. |
b |
Specify the second operand. |
Return Value
Returns the greater of a and b.
Exception
NA.
Example:
In the example below, the java.lang.Float.max() method returns the greater of passed two float arguments.
import java.lang.*; public class MyClass { public static void main(String[] args) { //creating float values float x = 5.2f; float y = 10.2f; //printing the max of two float values System.out.println("max(x, y) = " + Float.max(x, y)); } }
The output of the above code will be:
max(x, y) = 10.2
❮ Java.lang - Float