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 6223339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:28:18+00:00 2026-05-24T08:28:18+00:00

I was reading this book entitled, Cracking the Coding Interview by Laakman. There is

  • 0

I was reading this book entitled, Cracking the Coding Interview by Laakman. There is this part where she (the author p.g. 202) did:

byte[] bitfield = new byte [0xFFFFFFF/8];//there are 7 F's

She was allocating 4 billion bits. However, isn’t 0xFFFFFFF = 2^28-1? Thus, she has only allocated a byte array of 2^28-1/8 bytes, which is not remotely close to 4 billion bits. It is only 2^28-1 bits. My question is- is she wrong or am I doing something wrong? How do we allocate 4 billion bits? I have tried:

byte[] bitfield = new byte[0xfffffff *2];

Although the above causes the jvm to run out of heap space.

While we are at it, what is the best was to express hex values? e.g. 0xffffffff or 0xFFFFFFFF?

  • 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-05-24T08:28:19+00:00Added an answer on May 24, 2026 at 8:28 am

    It’s not clear to me why you’re multiplying by 2. It’s simplest to just take the hex representation of (4 billion / 8) – where by “4 billion” we really mean 0x100000000.

    So use 0x100000000 / 8, i.e. 0x2000000:

    byte[] array = new byte[0x20000000];
    

    That should be fine if you’ve given your JVM enough memory on startup, e.g. with -Xmx900M.

    Sample code:

    public class Test {
        public static void main(String[] args) {
            byte[] bytes = new byte[0x20000000];
        }
    }
    

    Run by default:

    c:\Users\Jon\Test>java Test
    Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
            at Test.main(Test.java:3)
    

    Run with a bit more space:

    c:\Users\Jon\Test>java -Xmx900M Test
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I'm reading a book (Pro ASP.Net Framework). In this book, the author suggests
I am reading this book called Java Concurrency in Practice and the author gives
I'm reading this book and there is a chapter about prototypes with this hard
I was reading this book. Explaing about @OneToOne unidirectional, the author has taken the
I'm reading this book on C# and .NET and I'm learning a bunch of
I'm reading this introductory book on parsing (which is pretty good btw) and one
I have the following text tooooooooooooon According to this book I'm reading, when the
I came across this class while reading a C# book and have some questions.
I was reading the Red Bean book and noticed this paragraph: Do not be
I'm currently reading the book Professional Enterprise .NET and I've noticed this warning in

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.