BigInteger.valueOf() in Java

BigInteger.valueOf() : This method is available in java.math.BigInteger class of Java.

Syntax:

BigInteger java.math.BigInteger.valueOf(long val)

This method takes one argument of type long as its parameter. This method returns a BigInteger whose value is equal to that of the specified long.

Parameters: One parameter is required for this method.

val: the value of the BigInteger to return.

Returns: a BigInteger with the specified value.

For Example:

long val = 91991

BigInteger.valueOf(val) = > It returns 91991.

Approach

Java


import java.math.BigInteger;

public class BigIntegervalueOf {

    public static void main(String[] args) {

        long val = 91991;
        System.out.println(BigInteger.valueOf(val));

    }
}

Output:

91991

No comments:

Post a Comment