How to find the max of 4 numbers in Java

2 Answers

0 votes
public class MyClass {
    public static void main(String args[]) {
        int a = 12, b = 150, c = 400, d = 389;
  
        System.out.println(Math.max(Math.max(Math.max(a, b), c), d));
    }
}
  
  
  
   
/*
run:
   
400
   
*/

 



answered Aug 17, 2021 by avibootz
0 votes
public class MyClass {
    public static void main(String args[]) {
        int a = 12, b = 150, c = 400, d = 38978;
  
        System.out.println(Math.max(Math.max(a, b), Math.max(c, d)));
    }
}
  
  
  
   
/*
run:
   
38978
   
*/

 



answered Aug 17, 2021 by avibootz
...