Java BigInteger testBit() MethodThe testBit() method of Java BigInteger class is used to check whether the designated bit is set or not. This method returns true if and only if the designated bit is set. This method computes (this & (1<<n)) != 0). Syntax:Parameter:n- index of the bit to test Returns:The method returns true if and only if the designated bit is set else it will return false. Exception:This method throws an ArithmeticException when n is negative. Example 1Test it NowOutput: Test Bit on 5 at index 2 returns true Test Bit on 5 at index 3 returns false Example 2Test it NowOutput: java.lang.ArithmeticException: Negative bit address Next TopicJava BigInteger |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India