Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,895 questions

51,826 answers

573 users

How to get larger (maximum) of the two arguments type int, float, long and double in Java

1 Answer

0 votes
package javaapplication1;

public class JavaApplication1 {
 
    public static void main(String[] args) {
        
        double d1 = 30.501;
        double d2 = 30.500;
        float f1 = 9.49f;
        float f2 = 9.50f;
        int i1 = 13;
        int i2 = 98;
        long l1 = 90000000;
        long l2 = 90000001;

        System.out.println(Math.max(d1, d2)); // double max(double arg1, double arg2)
        System.out.println(Math.max(f1, f2)); // float max(float arg1, float arg2)
        System.out.println(Math.max(i1, i2)); // int max(int arg1, int arg2)
        System.out.println(Math.max(l1, l2)); // long max(long arg1, long arg2)
    }
}
 
/*
run:

30.501
9.5
98
90000001
 
*/

 



answered Sep 8, 2016 by avibootz

Related questions

...