This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes the variable in static method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "the variable in static method" Watch "the variable in static method" New topic
Author

the variable in static method

lee dong
Greenhorn

Joined: Jun 04, 2005
Posts: 2
Hello everybody!
I want to konw is the variable in static method static too?
like that:


-------------------
How the static method and the variable in the static method orgnized in memory?

many thx!
Svend Rost
Ranch Hand

Joined: Oct 23, 2002
Posts: 904
A static method or variable belongs to a class (instead of an instance of
an object), and the static variables get initialized when the classes are
loaded.

a)
No, i is not a static var. It's a local variable.

b)
They are located (edit on the stack

/Svend Rost
[ January 30, 2006: Message edited by: Svend Rost ]
lee dong
Greenhorn

Joined: Jun 04, 2005
Posts: 2
Thank you!
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Svend Rost:

They are located in the heap area.


No, local variables always are located on the stack.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Svend Rost
Ranch Hand

Joined: Oct 23, 2002
Posts: 904
Originally posted by Ilja Preuss:


No, local variables always are located on the stack.


Sorry - I was to careless to look it up.. Thanks for correcting me.

/Svend Rost
Chandrasekhar Mangipudi
Ranch Hand

Joined: Jan 29, 2006
Posts: 118
Methods which belongs to static and non-static can have Local variables. so "i" is a local variable.It needs to be intialized before using the variable.


Thanks & Regards,
ChandraSekharMangipudi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: the variable in static method