Java Data Type Tutorial - Java BigInteger.flipBit(int n)








Syntax

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

public BigInteger flipBit(int n)

Example

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

/*from   ww w.  j av  a 2s . c o  m*/
import java.math.BigInteger;

public class Main {

  public static void main(String[] args) {

    // assign value to bi1
    BigInteger bi1 = new BigInteger("8");// 1000

    // perform flipbit operation on bi1 with index 1
    BigInteger bi2 = bi1.flipBit(1);

    System.out.println(bi2);
  }
}

The code above generates the following result.