Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions? | Software Development
 

Java BigInteger max value

We can use the max() method of the BigInteger class to get the maximum value of the two BigInteger values.

Java BigInteger max value

                         

We can use the max() method of the BigInteger class to get the maximum value of the two BigInteger values. It returns the BigInteger value whose value is  greater of this and the passed variable. If in case these are equal, any of them may be returned.

Syntax of max() method of BigInteger class is as follows:

public BigInteger max(BigInteger val)

In our java example code we have created three BigInteger variables and we have then compared them with the use of max() method.

BigInteger maxResult = bigInteger1.max(bigInteger2);

Variable maxResult returns the BigInteger value of either of the bigIntger1 or of bigInteger2 which is maximum.Here is the full example code of the example code as follows:

import java.math.BigInteger;
public class BigIntegerMaxValue
{
    public static void main(String[] args
    {
    BigInteger bigInteger1 = new BigInteger ("123456789");
    BigInteger bigInteger2 = new BigInteger ("112334");
    BigInteger bigInteger3 = new BigInteger ("987654321");
    BigInteger maxResult = bigInteger1.max(bigInteger2);
    System.out.println("Max big integer in"+bigInteger1+
    
" and "+bigInteger2+" is ==>" + maxResult);
    maxResult = bigInteger1.max(bigInteger3);
    System.out.println("Max big integer in"+bigInteger1+
   
" and "+bigInteger3+" is ==>" + maxResult);
    }
}

Output of the example is as follows:

C:\biginteger>javac BigIntegerMaxValue.java

C:\biginteger>java BigIntegerMaxValue
Max big integer in123456789 and 112334 is ==>123456789
Max big integer in123456789 and 987654321 is ==>987654321

Download Source Code

                         

» View all related tutorials
Related Tags: c string data convert integer variable type vi rsa int ria biginteger long to bi e il can var pe

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
 
Tell A Friend
Your Friend Name

 

 
Recently Viewed
Software Solutions
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.