How to Use Math.max(x,y) in Java


In this example we will show you how to use math.max(x,y) to return the highest value of x and y in Java.

Source Code

package com.beginner.examples;

public class Max {
  public static void main(String[] args) {
    System.out.println(Math.max(2, 7)); // return the highest value
  }
}

Output:

7
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments