max(): This method is available in the Math class of Java.
Syntax:
double java.lang.Math.max(double a, double b)
This method takes two arguments of type double as its parameter. This method returns the greater of two double values.
Parameters: Two parameters are required for this method.
a: First argument.
b: Second argument.
Returns: The larger of a and b.
For Example:
Math.max(1717.2828, 18818.818) => It returns 18818.818
Approach
Java
public class MaxDouble {public static void main(String[] args) {double a = 1717.2828, b = 18818.818;System.out.println(Math.max(a, b));}}
Output:
18818.818
No comments:
Post a Comment