Java BigInteger.setBit(int n)

Syntax

BigInteger.setBit(int n) has the following syntax.

public BigInteger setBit(int n)

Example

In the following code shows how to use BigInteger.setBit(int n) method.


/*w  ww. j  a  va2s .com*/

import java.math.BigInteger;

public class Main {

  public static void main(String[] args) {

    BigInteger bi1 = new BigInteger("7");

    // perform setbit operation on bi1 using index 3
    BigInteger bi2 = bi1.setBit(3);

    System.out.println(bi2);
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.math »




BigDecimal
BigInteger