How does Java associate a variable name with a location in memory? -


how java associate variable name location in memory?

my first thought there must static table used variable names associates either it's value or location it's value. exist , there formal name table?

the value of variable of primitive type number , value of variable of reference type reference (usually memory address).

now question is: stored value of given variable. depends on the kind of variable - there local variables, instance variables (fields) , class variables (static fields).

names of locals resolved during compilation. each variable becomes i-th variable in method , stored i-th variable in stack frame of method call.

for instance variables different. field names present in bytecode (but not present in machine code generated jit compiler). objects of given class have same layout, class can store offset of given field - distance beginning of object. interpreter can read address of object , add offset calculate variable stored.

class variables similar instance variables, simpler. in case, class stores both names , values of variables.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -