Math.max only takes two arguments. If you want the maximum of three, use Math.max(MY_INT1, Math.max(MY_INT2, MY_DOUBLE2)).

Answer from Jeremiah Willcock on Stack Overflow
🌐
CodeGym
codegym.cc › java blog › java math › java math max() method
Java Math.max() method with Examples
December 5, 2024 - public class Main { public static void main(String args[]) { double x = 15.68; double y = -37.47; System.out.println(Math.max(x, y)); } } The output will be 15.68 Finding the maximum value between two floating-point numbers. public class Main { public static void main(String args[]) { float x = -21.44f; float y = -23.32f; System.out.println(Math.max(x, y)); } } The output will be -21.44f Finally, let’s find the maximum value between the two long values.
People also ask

What is the purpose of the Math.max() function in Java?
The primary purpose of Math.max() is as a programming tool that discovers the biggest number between any two input numbers using an effective mathematical detection method.
🌐
upgrad.com
upgrad.com › home › tutorials › software & tech › the max function in java
Max Function in Java: A Complete Guide with Practice Exercises
Does Math.max() work with negative numbers?
Yes, the Math.max() function in JavaScript verifies negative numbers throughout its execution to provide the highest value from all arguments regardless of their sign.
🌐
upgrad.com
upgrad.com › home › tutorials › software & tech › the max function in java
Max Function in Java: A Complete Guide with Practice Exercises
Can Math.max() be used to compare more than two numbers?
The original goal of Math.max() in Java and JavaScript matches only two numbers yet programmers can obtain a multiple number maximum through sequential function execution or alternative solution approaches.
🌐
upgrad.com
upgrad.com › home › tutorials › software & tech › the max function in java
Max Function in Java: A Complete Guide with Practice Exercises
🌐
DaniWeb
daniweb.com › programming › software-development › threads › 172908 › max-and-min-of-more-than-2-numbers
java - Max and Min of more than 2 numbers | DaniWeb
I just started programming in Java and i dont think i would know how to program a method to make it detect the min/max in an array. is there any method to just use the Math.min/Math.max for trying to see which one is the largest/smallest from the users input? ... Besides, if you simply want to "take the easy way out", place your numbers in an array (which I assume they are already, anyway), and use Arrays.sort() and then pull the first and last numbers.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-program-to-find-the-largest-of-three-numbers
Java Program to Find the Largest of three Numbers - GeeksforGeeks
import java.lang.*; import java.util.*; ... System.out.println(Collections.max(x) + " is the largest number."); } } Output · 10 is the largest number....
Published   November 21, 2020
🌐
Codecademy
codecademy.com › docs › java › math methods › .max()
Java | Math Methods | .max() | Codecademy
October 22, 2022 - Learn to code in Java — a robust programming language used to create software, web and mobile apps, and more. Beginner Friendly.Beginner Friendly17 hours17 hours ... The .max() method takes two parameters num1 and num2. num1 and num2 can be of type int, float, double or long. The following example uses the .max() method to print the maximum of two numbers:
Find elsewhere
🌐
TutorialsPoint
tutorialspoint.com › java-program-to-find-maximum-of-three-numbers
Java program to find maximum of three numbers
In this program, we initialize three integer variables, num1, num2, and num3, with the values 15, -5, and 7 respectively. We then use an if statement to compare the values. We check if num1 is greater than or equal to both num2 and num3. If this condition is true, num1 is the maximum number, and ...
🌐
W3Schools
w3schools.com › java › ref_math_max.asp
Java Math max() Method
Tip: Use the min() method to return the number with the lowest value. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com · If you want to report an error, or if you want to make a suggestion, send us an e-mail: help@w3schools.com · HTML Tutorial CSS Tutorial JavaScript Tutorial How To Tutorial SQL Tutorial Python Tutorial W3.CSS Tutorial Bootstrap Tutorial PHP Tutorial Java Tutorial C++ Tutorial jQuery Tutorial
🌐
Upgrad
upgrad.com › home › tutorials › software & tech › the max function in java
Max Function in Java: A Complete Guide with Practice Exercises
March 18, 2025 - We utilize the Math.max() method two times to assess the three numbers: Initially, it determines the higher value between num1 and num2. Next, it evaluates the outcome against num3 to determine the overall maximum.
🌐
Quora
quora.com › How-do-I-find-the-largest-of-three-integers-in-Java
How to find the largest of three integers in Java - Quora
Answer (1 of 6): General logic to find the largest of 3 numbers is like the number which is greater than the other 2 numbers. Let 3 integers be num1,num2,num3 Num1 is largest if num1>num2 and num2>num3 Similarly the other 2 numbers.
🌐
Tutorialspoint
tutorialspoint.com › java › lang › math_max_int.htm
Java - Math max(int x, int y) Method
package com.tutorialspoint; public class MathDemo { public static void main(String[] args) { // get two int numbers int x = -60984; int y = -497; // call max and print the result System.out.println("Math.max(" + x + "," + y + ")=" + Math.max(x, y)); } } Let us compile and run the above program, this will produce the following result − · Math.max(-60984,-497)=-497 · java_lang_math.htm ·
🌐
Scaler
scaler.com › home › topics › max function in java
Max Function in Java - Scaler Topics
April 20, 2024 - The first answer is you compare both real numbers using comparison operators like greater-than (>) or less-than (<) operators and find the maximum number. The second method is to take the help of the inbuilt max() method of Math class in Java ...
🌐
Javatpoint
javatpoint.com › java-math-max-method
Java Math.max() method with Examples - Javatpoint
Java Math.max() method with Examples on abs(), min(), max(), avg(), round(), ceil(), floor(), pow(), sqrt(), sin(), cos(), tan(), exp() etc.
🌐
TutorialKart
tutorialkart.com › java › java-math › java-math-max
Java Math.max() - Maximum Value
November 23, 2020 - In the following example, we use ... public static void main(String[] args) { long a = 1099859955445L; long b = 58978542L; long result = Math.max(a, b); System.out.println(result); } }...
🌐
Java67
java67.com › 2019 › 05 › how-to-find-largest-and-smallest-of-three-numbers-in-java.html
How to Find the Largest and Smallest of Three Numbers in Java? [Solved] | Java67
import java.util.Scanner; /* * Java Program to find largest and smallest of three numbers */ public class Main { public static void main(String args[]) { // creating scanner to accept radius of circle Scanner scanner = new Scanner(System.in); System.out.println("Welcome in Java program to find largest and smallest of three numbers"); System.out.println("Please enter first number :"); int first = scanner.nextInt(); System.out.println("Please enter second number :"); int second = scanner.nextInt(); System.out.println("Please enter third number :"); int third = scanner.nextInt(); int largest = la
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-math-max-method
Java Math max() Method - GeeksforGeeks
May 14, 2025 - // Java program to demonstrate ... static void main(String args[]) { int a = 23; int b = -23; // prints the maximum of two numbers System.out.println(Math.max(a, b)); } } ... Example 3: In this example, we will see the usage ...
🌐
Blogger
java-demos.blogspot.com › 2013 › 10 › find-maximum-and-minimum-of-numbers.html
Find Maximum and Minimum of numbers — Java Demos
In this example, i will be showing you how to find maximum and minimum of three numbers. But before that let us take a look at the prototype of these methods. public int max(int,int) public int min(int,int) Note that there are overloaded versions of these methods which differ in type. As these methods doesn't depend upon any member variables of the class, it is declared static, so can be accessed directly via the class name. import java.util.*; class MaxMin { public static void main(String args[]) { Scanner s=new Scanner(System.in); System.out.println("Enter three numbers"); // Take three ints int a=s.nextInt(); int b=s.nextInt(); int c=s.nextInt(); // Two is just common, let's try three!