Last Updated : 11 Jul, 2025
Prerequisite:
BigInteger Basicspublic BigInteger max(BigInteger val)Parameters: The method accepts one parameter val which refers to the value with which the maximum is to be computed. Return Value: The method returns the BigInteger whose value is the greater of this and val. If they are equal, either may be returned. Below program illustrate max() method of BigInteger class. Java
/*
*Program Demonstrate max() method of BigInteger
*/
import java.math.*;
public class GFG {
public static void main(String[] args) {
// Create 2 BigInteger objects
BigInteger biginteger=new BigInteger("8976543245");
BigInteger val=new BigInteger("9248040402");
// Call max() method to find greater value
// between two BigIntegers.
BigInteger biggerInteger = biginteger.max(val);
String result = "Bigger Integer between "+biginteger+" and "
+val+ " is " +biggerInteger;
// Prints the result
System.out.println(result);
}
}
Output:
Bigger Integer between 8976543245 and 9248040402 is 9248040402
public BigInteger min(BigInteger val)Parameters: The method accepts one parameter val which refers to the value with which the minimum is to be computed. Return Value: The method returns the BigInteger whose value is the lesser of this and val. If the values are equal, either may be returned. Below program illustrate min() method of BigInteger class. Java
/*
*Program Demonstrate min() method of BigInteger
*/
import java.math.*;
public class GFG {
public static void main(String[] args) {
// Create 2 BigInteger objects
BigInteger biginteger=new BigInteger("5782539631");
BigInteger val=new BigInteger("3592633823");
// Call min() method to find lesser value
// between two BigIntegers.
BigInteger biggerInteger = biginteger.min(val);
String result = "lesser Integer between "+biginteger+" and "
+val+ " is " +biggerInteger;
// Prints the result
System.out.println(result);
}
}
Output:
lesser Integer between 5782539631 and 3592633823 is 3592633823
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4