Java BigInteger max() Method

The max() method of Java BigInteger class is used to get the maximum value of the two BigInteger objects. This method returns the BigInteger whose value is greater of this BigInteger and the val method argument.

Syntax:

Parameter:

val - value with which the maximum is to be computed.

Exception:

NA

Returns:

This method returns the BigInteger whose value is the greater between this and val.

  • If this and val both are equal, either may be returned.
  • If this is greater than val, this will be returned.
  • If val is greater than this, val will be returned.

Example 1

Test it Now

Output:

Maximum value among 12345 and 12345 is 12345

Example 2

Test it Now

Output:

Maximum value among 100 and 10 is 100

Example 3

Test it Now

Output:

Maximum value among -100 and -10 is -10

Next TopicJava BigInteger




Latest Courses