Java BigInteger valueOf() method

The valueOf() method of Java BigInteger class returns a BigInteger whose value is equal to that of the specified long.

Syntax:

Parameter:

val - value of the BigInteger to return.

Returns:

This method returns a BigInteger with the specified value.

Exception:

NA

Note: This static factory method is provided in preference to a (long) constructor because it allows for reuse of regularly used BigIntegers.

Example 1

Test it Now

Output:

BigIntger value of Long 123456789 is 123456789

Example 2

Test it Now

Output:

BigIntger value of Long 25 is 25

Example 3

Test it Now

Output:

BigIntger value of Long 12345 is 12345

Next TopicJava BigInteger




Latest Courses