Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7797339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:39:11+00:00 2026-06-01T23:39:11+00:00

The Java reference here indicates that boolean types, while represented with a bit of

  • 0

The Java reference here indicates that boolean types, while represented with a “bit” of information, do not have a precisely defined size. In contrast, other types seem to suggest that the size is defined. For example, an int is 32-bits, end of story.

When we look at the spec for a BitSet, we can see that it is composed of boolean values. By the reference above, this seems to suggest that the “size” of a BitSet is undefined – it’s composed of boolean values, after all. And sure enough, the documentation specifies:

Note that the size is related to the implementation of a bit set, so it may change with implementation.

So my question is, why not implement a BitSet using another datatype that is precisely defined? For example, if we use a byte, we could guarantee a size of 8-bits, and we wouldn’t have the fuzzy feeling that the size may not be what we think it is. It’s true that the size would have to be divisible by 8, but at least it seems more size-deterministic this way.

If we have a system that absolutely cannot exceed a certain memory capacity, it seems useful to have a BitSet implementation that is precise in terms of size.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:39:13+00:00Added an answer on June 1, 2026 at 11:39 pm

    I think that you’re getting conceptually stuck by the fact that the method signatures use booleans.

    The easiest way to think about a single bit is off/on, so a boolean true/false is a convenient way to model it. Another thing entirely is the BitSet internal storage, which if you have a look at the source code, is using a long array and using bitmasks to twiddle individual bits.

    Accordingly, the size of the BitSet is tied pretty closely to the number of bits in use.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have plain Jar Project that reference by android application. Then, I have Functions.java
I've been looking around here for any reference to a java library for visual
I have read Java Concurrency in Practice and this is a great reference, but
I know that when it comes to passing objects in java, the reference of
I read this comment here: Passing a String by Reference in Java? Yes, it's
Java doesn't pass variables by reference. In that case, how do data structures like
I learned that Servlet reference implementation is included in the Java EE SDK. And
What am I missing here? http://www.ibm.com/developerworks/java/library/j-pg10255/index.html In reference to Listing 1: Why is lamp1
Possible Duplicate: Is Java pass-by-reference? I am a little confused here. How does Arrays.sort(a)
Possible Duplicate: what happens to an object in Java if you do not reference

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.