Java BitSet clear() methodThe clear() method of Java BitSet class is used to set the bits in the BitSet to false. There are various overloaded clear() methods available in BitSet class. 1. Java BitSet clear() methodThe clear() method set all the bits in the BitSet to false. 2. Java BitSet clear(int bitIndex) methodThe clear(int bitIndex) method set the bit of specified index to false. 3. Java BitSet clear(int fromIndex, int toIndex) methodThe clear(int fromIndex, int toIndex) method set the bits to false from specified inclusive fromIndex to exclusive toIndex. Syntax:Parameter:
Returns:NA Exception:
Compatibility Version:
Example of Java BitSet clear() method Example 1Output: bitset: {0, 1, 2, 3, 4} result bitset: {} Example of Java BitSet clear(int bitIndex) method Example 2Output: bitset: {5, 10, 15, 20, 25} result bitset: {5, 15, 20, 25} Example 3Example of Java BitSet clear(int fromIndex, int toIndex) method Output: bitset: {5, 10, 15, 20, 25} result bitset: {5, 25} Next TopicJava-bitset-andnot-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