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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:34:45+00:00 2026-06-08T17:34:45+00:00

An object can contain references to other objects. If you declare these references as

  • 0

An object can contain references to other objects. If you declare these references as class/field variables then as the object itself is created on the heap, the values represented by the field references are stored on the heap.

So, if i have

public class A {
    int size;
}
  • I know that if size gets an int value of 2 then that is stored as part of the object on the heap, but where is the reference i.e. the name size stored ?
  • Is the name “size” also stored inside of the object on the heap.
  • How does JVM cross-reference size == 2 on the heap ?
  • When you load up the class it runs in the main thread and each thread will have its own stack. So these field references are not created on the main stack correct?
  • 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-08T17:34:47+00:00Added an answer on June 8, 2026 at 5:34 pm

    Where is the name “size” stored?

    The name of the field is stored in the Class object A.class. You can inspect class field names by using the java.lang.reflect library.

    For example, to inspect all the fields of a class, do this:

    for (Field field : A.class.getFields()) {
        String fieldName = field.getName();
        Class<?> fieldClass = field.getType();
        // etc
    }
    

    Is the name “size” also stored inside of the object on the heap?

    No. It is stored in permgen memory

    How does JVM cross-reference size == 2 on the heap?

    It looks up the field at compile time and the rest happens in bytecode

    Field references are not created on the main stack?

    No. There are more memory areas than just heap and stack, There is also permgen, where the class definitions and class fields are stored. There still more memory areas, for example for the garbage collector.

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

Sidebar

Related Questions

I have an object that can contain references to other objects of the same
Let us say my domain object can contain a bunch of objects like this:
I have beans which have Objects which can contain different types. Now when I
In prototypal languages object can basically clone each other. So, lets say we have
In android I can Log(aa,+Object) ,then the object can as string to print,it can
I have a bunch of Excel.Name objects under Workbook.Names collection which contain invalid references.
Do class objects declared on the stack have the same lifetime as other stack
I need a collection in which i can store heap-allocated objects having virtual functions.
I have an array that contains @sign in the object. I can't access that
I have a LinkedList that contains many objects. How can I find the number

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.