Java BigInteger setBit() Method20 Mar 2025 | 2 min read The setBit() method of Java BigInteger class is used to set the bit position. This method returns a BigInteger whose value is equivalent to this BigInteger with the designated bit set. Syntax:Parameter:n- Index of the bit to set entered by the user. Returns:This method returns ( this | (1<<n)). Exception:ArithmeticException - n is negative. Example 1Output: SetBit operation on 5 at index 1 gives 7 Example 2Output: java.lang.ArithmeticException: Negative bit address Example 3Output: SetBit operation on 5 at index 2 gives 5 Next TopicJava BigInteger |
We request you to subscribe our newsletter for upcoming updates.

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