I'm going to explain here about importance of "static" keyword in java. "static" can be applied to a class variable, or method, or even for a code block within a class. Static variables, static methods, and static blocks are stored in method are of JVM. Please click here to learn more about JVM architecture.

Static variable: A static variable is a variable whose single copy in memory is shared by all the objects of the class. So, any modification to the static variable will be reflected on all objects. Static variables are used to maintain common values which can be shared across all the objects of the class. Eg: Math class has got a static constant "PI", which is a common constant value can be shared across all the Math class objects.

Syntax: <access-specifiers> static <data type> <variable name>;
Eg: public final static float PI;

Static method: A static method is a method that can be called and executed without creating an object. In general, static methods are used to create instance methods.

Static method can be invoked directly via class name i.e.; we don't have to create an object for a class in order to initiate static method.

Any stand alone Java program needs a main method which is static. "main()" method has to be declared as static because JVM calls it directly without creating an object to a class.

Syntax: <access-specifiers> static <return type> <method name>(<arguments>);
Eg: public static void main(String args[])

Static block: "static" block is a code block followed by static keyword. The static block can be declared as part of the class definition which will be invoked by JVM automatically when class is loaded into JVM's memory.
Syntax:
static
{
   --------;
   --------;
   --------;
}

StaticDemo.java
/**
* A demo class to explain about Static methods, variables, and blocks
* @author Santhosh Reddy Mandadi
* @since 02-Mar-2012
* @version 1.0
*/

public class StaticDemo
{
//Static variable to hold how many times a method has been invoked on this class
private static int methodCallingCounts = 0;

//Static block to be executed when the class file is loaded
static
{
methodCallingCounts = 0;
System.out.println("Class is loaded... and I'm executed!");
}

//Static method
public static int getMethodCallingCounts()
{
return ++methodCallingCounts;
}

public static void main(String args[]) throws Exception
{
methodCallingCounts++;
System.out.println("Method calling count..."+getMethodCallingCounts());
StaticDemo x = new StaticDemo();
StaticDemo y = new StaticDemo();
System.out.println("Method calling count from x..."+x.getMethodCallingCounts());
System.out.println("Method calling count from y..."+y.getMethodCallingCounts());
}
}




Above program has been tested in 1.5 and 1.6.

Click here to check out other programs that I've developed.