For example once the variable of class has declared as static one permanent memory
will be allocated in heap memory.
Even when ever the new variable has created for the class the instance of the class
will be same.
So its called as one time initialization.
Static can be used in Method, Class, Variable.
Lets see the difference of static class and static variable and static methods.
One the static class declared we can access the class using its name without
creating the instance of the class because it has one time initialization.
Once the variable has declared with static then the variable value is single and
never be dynamic
Once the method is declared with static the same method we can access using the
class name anywhere.
This is the simple majic about the static keyword in java.
No comments:
Post a Comment