1.Please let me know about what the static keyword means.
2.Is it possiblle to define the static and write its method inside it such as
static {
some implementations;
}
3.Also where does the control goes when java compiler encounters the word static ? when do we actually use static keyword.
Hi
1. static keyword states that your variable is associated with the class. For example you are having one class X and
you are instating 05 objects from this class. The 05 objects can have a different value for a single variable. But with the
case of static variable all 05 objects will be having the same value. However each object or class can change the value
the static varable. The value changed by one object will be reflected by all objects. Or you can understand it like a common variable for the class and all the objects of that class.
2. Yes , you can do it. This is known as static block, which is executed once class is loaded.
3. static can be used to count the counter of a web site, or to store the value in the static variable which is required throughout the application, etc.