bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java Math max() Method

❮ Math Methods

Example

System.out.println(Math.max(2.0, 0.25));
System.out.println(Math.max(31.2f, 18.0f));
System.out.println(Math.max(14, 22));
System.out.println(Math.max(96L, 2048L));

Definition and Usage

The max() method returns the number with the highest value from a pair of numbers.

Tip

Use the min() method to return the number with the lowest value.

One of the following

public static double max(double
x , double
y )
public static float max(float
x , float
y )
public static int max(int
x , int
y )
public static long max(long
x , long
y )

Parameter Values

ParameterDescription
xRequired. A number.
yRequired. A number.

Technical Details

Returns:A double , float , int or long value representing the highest of two numbers.
Java version:Any

Previous

Java Math log1p() Method

Next

Java Math min() Method