wood burning stoves 2.0*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Base Address for Java primitives" Watch "Base Address for Java primitives" New topic
Author

Base Address for Java primitives

ashokshiv
Greenhorn

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.
i.e.
class X
{
public int i;
i=3;

.......
.......
}
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


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

Joined: Mar 22, 2000
Posts: 12761
    
    5
This question reveals that you are just starting in Java and object oriented programming. You should probably read the free Sun tutorial - java.sun.com 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.
Bill
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

"ashokshiv"
your name doesn't agree with the javaranch guidelines.
please take a moment and re-register after reviewing the
guidelines at http://www.javaranch.com/name.jsp
thanks for your cooperation.
- satya

Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
ashokshiv
Greenhorn

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.
ashok
 
Consider Paul's rocket mass heater.
 
subject: Base Address for Java primitives
 
Similar Threads
assigning a final value to a method local variable
can someone explain?
casting
java