File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Base Address for Java primitives Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Base Address for Java primitives" Watch "Base Address for Java primitives" New topic

Base Address for Java primitives


Joined: Jul 23, 2001
Posts: 3
Hi all,
This is ashok here in India.
I came accross the following doubt.
Suppose i have a class which is having primitive variables.
class X
public int i;

Please try to understand what i want to convey exactly.
In the above situation i want to know about the base address of primitive variable i. I mean when will the base address of var i be assigned ? whether at Compile time or Run time.
If i assume that it is assinged at Compile time. Thereafter i am restarting the computer after compiling the java file,
and then running the X.class file without recompiling it. But in this case it should give the MemoryNotFound error (like it) , because what memory assigned at compile time must lost due to restart the computer right.
But if it is assigned at run time then what is the use of symbol table.
Thanks for giving yr valuable it.
Please can u suggest me from where the answers of this type of questions i will get.
Thanks in advance.


Ashok Kumar Rajput
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
This question reveals that you are just starting in Java and object oriented programming. You should probably read the free Sun tutorial - is the place to start.
What is assigned at compile time is the address of a variable relative to the address of the object. The address of the object is assigned when a new instance is created, but it may be moved by garbage collection. As a Java programmer you NEVER HAVE TO WORRY about physical memory addresses.
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

your name doesn't agree with the javaranch guidelines.
please take a moment and re-register after reviewing the
guidelines at
thanks for your cooperation.
- satya

Take a Minute, Donate an Hour, Change a Life

Joined: Jul 23, 2001
Posts: 3
thank you for reply.
but for yr kind information i want to tell you one think that being a new i got 90% in SCJP 2 with new database.
and what u wrote that i knew Objects are allocated at Run Time after executing like new X().
But what i wanted to know that when the address for primitive vars be assigned.
I agree. Here's the link:
subject: Base Address for Java primitives
jQuery in Action, 3rd edition