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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:27:01+00:00 2026-06-11T17:27:01+00:00

Objects are fairly easy to understand in Java. The object is constructed, is allocated

  • 0

Objects are fairly easy to understand in Java. The object is constructed, is allocated space in the heap, and you assign it to a variable name (reference) that points to it. No big deal. But how are primitive types represented? And where are they located (stack or heap)?

I thought of this question when I was wondering what the Integer.toString(int) method might look like. It can’t parse the text because… it’s not text. It can’t invoke a toString() method explicitly or implicitly, because that would be both circular logic and a flagrant disregard for the fact that primitive types can’t have methods assigned to them (since they aren’t objects). I suppose it is logically possible for the method to have tons of if/else conditionals for all possible int values between Integer.MIN_VALUE and Integer.MAX_VALUE, but that also seems much more complicated than it should be.

So how does this work?

  • 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-11T17:27:02+00:00Added an answer on June 11, 2026 at 5:27 pm

    But how are primitive types represented?

    Instances of primitive types are represented as bit patterns in memory. So for example, an int is represented as 32 bits (4 bytes, 1 32-bit word).

    And where are they located (stack or heap)?

    Either. It depends on what kind of variable you hold the primitive value in.

    I was wondering what the Integer.toString(int) method might look like.

    The core of the method is a simple algorithm is a loop that repeatedly

    1. takes the last decimal digit by taking the number remainder 10, and
    2. divides the number by 10.

    Just like you would do if you were converting a binary number to decimal by hand.

    (For details, look at the source code. Every Sun / Oracle JDK includes the source code for the core libraries. Alternatively you can easily find the source code (in various versions) on the internet with a Google search.)

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

Sidebar

Related Questions

I was fairly sure that I had read (in Richter's C# book) that objects
I have a fairly large CRUD WinForm app that has numerous objects. Person, Enrollment,
In my data model I have a fairly common division between my objects/tables/data: Transactional
So I have a fairly standard LINQ-to-Object setup. var query = expensiveSrc.Where(x=> x.HasFoo) .OrderBy(y
I am writing a fairly large C++ shared-object library, and have run into a
I have a fairly involved managed data model which has a central object with
example: foreach($boxes as $box) { echo $box \n; } Used to be fairly easy,
I'm looking for a C++ container-like class that wraps a typed array of objects
I'm trying to achieve a fairly easy triggering mechanism for deleting multiple items from
I've got a, I think fairly easy question, but this is bugging me for

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.