How to find the maximum of two numbers using Math.max() method in Java

1 Answer

0 votes
package javaapplication1;

public class JavaApplication1 {

    public static void main(String[] args) {

        System.out.println(Math.max(10, 30));
        
        System.out.println(Math.max(-10, -30));

        System.out.println(Math.max(3.14f, 3.15F)); // float 

        System.out.println(Math.max(1233.5764, 1233.5765)); // double 

        System.out.println(Math.max(10000000l, 10000001L)); // long
    }
}
   
/*
      
run:

30
-10
3.15
1233.5765
10000001
  
*/

 



answered Nov 8, 2016 by avibootz

Related questions

...