Java BitSet size() methodLast Updated : 17 Mar 2025 The size() method of Java BitSet class returns the total number of bit space actually in use by this BitSet to represent bit values. The maximum element in the set is the size - 1st element. The default size of the bit set is 64-bit space. If the bit is set at index larger than the current BitSet size, it increases its bit space in the multiplication of 64*n, where n starts from 1, 2, 3, so on. Syntax:Parameter:NA Returns:This method returns the number of bits space currently in this bit set. Exception:NA Compatibility Version:Java 1.0 and above Example 1Output:
bitset1: {1, 2, 4, 63}
bitset2: {10, 20, 30, 40, 64}
size of bitset1: 64
size of bitset2: 128
Next TopicJava-bitset-set-method |
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India