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








Syntax

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

public boolean testBit(int n)

Example

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

//from   ww w  . ja  va  2  s .c o  m
import java.math.BigInteger;

public class Main {

  public static void main(String[] args) {

    BigInteger bi = new BigInteger("10");

    Boolean b1 = bi.testBit(2);
    Boolean b2 = bi.testBit(3);
    // print b1, b2 values
    System.out.println(b1);
    System.out.println(b2);
  }
}

The code above generates the following result.