• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

static block

 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Heap.
 
A Babu
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The static variables are initialized before the instance variables.
 
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 1249
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic