Hi, Rajaraman!
public class Q {
static int numOfObjects;
public Q() {
numOfObjects++;
}
public static void main(
String[] args) {
new Q();
new Q();
new Q();
System.out.println(Q.numOfObjects);
}
}
This little class illustrates what static does. Static members are NOT associated with any special objects, but rather with the class as a whole (EVERY object created of the class).
The simplest usage of static is to create a variable that keeps track of how many objects that have been created of the class. This is what the varable 'numOfObjects' does in the above code. Every time you create an object using the new keyword, the counter 'numOfObjects' gets incremented.
You can reach a static variable (or method) by using the class name and the dot operator - as above: Q.numOfObjects. You never need an instance of a class to reach its static members.
I hope this helps!
/Kaspar