Two Laptop Bag*
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
JavaRanch » Java Forums » Java » Java in General
Bookmark "static block" Watch "static block" New topic
Author

static block

Vallabhaneni Suresh Kumar
Ranch Hand

Joined: Mar 01, 2004
Posts: 68
What is the purpose of static block and what does it mean?

Thank you
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
You're probably familiar with how static variables are initialized the first time you reference a class (when the class is loaded). Static blocks are executed at the same time. That gives you a neat way to do a little more work than a single initial value. For example:

We could even move all those states into a static method and call it from the static block. Neat, huh?


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: static block