Java BitSet previousClearBit() methodThe previousClearBit(int fromIndex) method of Java BitSet class returns the index of the nearest bit which is set to false (clear) that occurs on or before the specified index. It returns -1 if the specified index is negative or no such clear bit exists in the BitSet. Syntax:Parameter:
Returns:This method returns the index of the previous clear bit, or -1 if there is no such clear bit exists. Exception:IndexOutOfBoundsException - throw an exception if the specified index is negative. Compatibility Version:Java 1.7 and above Example 1Output: bitset: {0, 1, 3, 4} previous clear bit on or before 1: -1 previous clear bit on or before 4: 2 previous clear bit on or before 2: 2 Example 2The previousClearBit(int fromIndex) method returns -1 if the specified index is negative. Output: bitset: {0, 1, 3, 4} clear bit previous to -1: -1 Next TopicJava-bitset-or-method |
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