- Java.util - WeakHashMap
- Java.util - Vector
- Java.util - UUID
- Java.util - TreeSet
- Java.util - TreeMap
- Java.util - TimeZone
- Java.util - TimerTask
- Java.util - Timer
- Java.util - StringTokenizer
- Java.util - Stack
- Java.util - SimpleTimeZone
- Java.util - ServiceLoader
- Java.util - Scanner
- Java.util - ResourceBundle.Control
- Java.util - ResourceBundle
- Java.util - Random
- Java.util - PropertyResourceBundle
- Java.util - PropertyPermission
- Java.util - Properties
- Java.util - PriorityQueue
- Java.util - Observable
- Java.util - Locale
- Java.util - ListResourceBundle
- Java.util - LinkedList
- Java.util - LinkedHashSet
- Java.util - LinkedHashMap
- Java.util - IdentityHashMap
- Java.util - Hashtable
- Java.util - HashSet
- Java.util - HashMap
- Java.util - GregorianCalendar
- Java.util - Formatter
- Java.util - EnumSet
- Java.util - EnumMap
- Java.util - Dictionary
- Java.util - Date
- Java.util - Currency
- Java.util - Collections
- Java.util - Calendar
- Java.util - BitSet
- Java.util - Arrays
- Java.util - ArrayList
- Java.util - ArrayDeque
- Java.util - Home
Java.util Package Extras
- Java.util - Discussion
- Java.util - Useful Resources
- Java.util - Enumerations
- Java.util - Exceptions
- Java.util - Interfaces
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Java BitSet Class
Introduction
The Java BitSet class implements a vector of bits that grows as needed.Following are the important points about BitSet −
A BitSet is not safe for multithreaded use without external synchronization.
All bits in the set initially have the value false.
Passing a null parameter to any of the methods in a BitSet will result in a NullPointerException.
Class declaration
Following is the declaration for java.util.BitSet class −
pubpc class BitSet extends Object implements Cloneable, Seriapzable
Class constructors
Sr.No. |
Constructor & Description |
---|---|
1 |
BitSet() This constructor creates a new bit set. |
2 |
BitSet(int nbits) This constructor creates a bit set whose initial size is large enough to exppcitly represent bits with indices in the range 0 through nbits-1. |
Class methods
Sr.No. |
Method & Description |
---|---|
1 |
This method performs a logical AND of this target bit set with the argument bit set. |
2 |
This method clears all of the bits in this BitSet whose corresponding bit is set in the specified BitSet. |
3 |
This method returns the number of bits set to true in this BitSet. |
4 |
This method sets all of the bits in this BitSet to false. |
5 |
This method clones this BitSet and produces a new BitSet that is equal to it. |
6 |
This method compares this object against the specified object. |
7 |
This method sets the bit at the specified index to the complement of its current value. |
8 |
This method returns the value of the bit with the specified index. |
9 |
This method returns the value of the bit with the specified index. |
10 |
This method returns true if the specified BitSet has any bits set to true that are also set to true in this BitSet. |
11 |
This method returns true if this BitSet contains no bits that are set to true. |
12 |
This method returns the "logical size" of this BitSet: the index of the highest set bit in the BitSet plus one. |
13 |
This method returns the index of the first bit that is set to false that occurs on or after the specified starting index. |
14 |
This method returns the index of the first bit that is set to true that occurs on or after the specified starting index. |
15 |
This method performs a logical OR of this bit set with the bit set argument. |
16 |
This method returns the index of the first bit that is set to false that occurs on or before the specified starting index. |
17 |
This method returns the index of the first bit that is set to true that occurs on or after the specified starting index. |
18 |
This method sets the bit at the specified index to true. |
19 |
This method returns the number of bits of space actually in use by this BitSet to represent bit values. |
20 |
This method returns a stream of indices for which this BitSet contains a bit in the set state. |
21 |
This method returns a new bit set containing all the bits in the given byte array. |
22 |
This method returns a new long array containing all the bits in this bit set. |
23 |
This method returns a string representation of this bit set. |
24 |
This method returns a new bit set containing all the bits in the given byte array. |
25 |
This method performs a logical XOR of this bit set with the bit set argument. |
Methods inherited
This class inherits methods from the following classes −
java.util.Object