Online Java Compiler By
JavaTpoint.com
import java.math.BigInteger; public class BigIntegerTestBitExample1{ public static void main(String[] args){ // create a BigInteger object BigInteger big1; // create 2 Boolean objects Boolean bool1,bool2; // assign value to big1 big1= new BigInteger("5"); // perform testBit on big1 at index // assume n = 2 and n=3 bool1= big1.testBit(2); bool2= big1.testBit(3); String str1 = " Test Bit on " + big1+" at index 2 returns "+bool1; String str2 = " Test Bit on " + big1+" at index 3 returns "+bool2; System.out.println(str1); System.out.println(str2); } }
Output