How to find the minimum of two numbers using Math.min() method in Java

1 Answer

0 votes
package javaapplication1;

public class JavaApplication1 {

    public static void main(String[] args) {

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

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

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

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

10
-30
3.14
1233.5764
10000000
  
*/

 



answered Nov 8, 2016 by avibootz

Related questions

...