Find maximum of two numbers using Math.max in Java
Description
The following code shows how to find maximum of two numbers using Math.max.
Example
/*from w w w . ja v a 2 s.c o m*/
public class Main {
public static void main(String[] args) {
System.out.println(Math.max(2, 4));
System.out.println(Math.max(3.4f, 4.3f));
System.out.println(Math.max(6.34, 1.45));
System.out.println(Math.max(4l, 5l));
}
}
The code above generates the following result.