int a = 4; int b = 7; int max = Math.max(a, b); System.out.println("Maximum value is: " + max);
double c = 3.5; double d = 5.8; double max = Math.max(c, d); System.out.println("Maximum value is: " + max);Output: Maximum value is: 5.8 The Math.max() method is part of the java.lang package, which is automatically imported in every Java program.