*
The moose likes Java in General and the fly likes static block 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 » Java in General
Bookmark "static block" Watch "static block" New topic
Author

static block

A Babu
Ranch Hand

Joined: Nov 28, 2005
Posts: 114
hi all,
I have static method ,static varible and static block is there.
in which hieararchy the memory is allocated.i mean first for which memory is allocated second for which and so on.

thanks in advance.

cheers,
babu.


Thanks,
www.Admakr.in
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Heap.


There is no emoticon for what I am feeling!
A Babu
Ranch Hand

Joined: Nov 28, 2005
Posts: 114
hi jeff,
I think you didn't get my question.I am aware of the place where the memory is allocated for these.My question is ,first, memory is allocated for static block or variable,or method.

cheers,
babu.
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
The static variables are initialized before the instance variables.
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
Originally posted by A Babu:
hi all,
I have static method ,static varible and static block is there.
in which hieararchy the memory is allocated.i mean first for which memory is allocated second for which and so on.

thanks in advance.

cheers,
babu.


Assignment of static variables occurs in a static initializer, unless they are compile-time constants (in which case their "memory" is allocated in the class literal pool), so they are the same thing. This occurs in order of their appearance (and that of other initalizers) in the source file. Static methods do not have memory allocated.


Tony Morris
Java Q&A (FAQ, Trivia)
Shaan Shar
Ranch Hand

Joined: Dec 27, 2005
Posts: 1249

Babu,

Actually you are on the wrong track, only static variable gets memory. Static Block and static methods doesn't memory. Although if you have static variable also in Methods and Blocks. then also static block will get first executed and all static variables get allocated then all static variable defined outside of the static block get allocated. I hope this will ease your problem.

Cheer Up Babu L.


The Best way to predict your future is to create it - Every great individual common man
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: static block
 
Similar Threads
Job of class Class in jdbc
static block or initialisation block
class.forname...working
doubt about "working memory"
static block