Static

 static keyword in Java

1.static keyword is an important element in java which is mainly used for memory manamgement.
2.static keyword can be used with variable,function and block.
3.static members belong to class rather than object of class so they can be called by class name directly.

1. static variable

1.The variable which is declared with static keyword is called static variable.
2.It is also called class level variable because it is common to all instances(object).
3.A static varible can be accessed anywhere in the program using class name.

2. static function

1.The function which is declared with static keyword is called static function or method.
2.A static function is also called by class name directly because it belongs to class rather than object.

3. static block

It is such type of block that executes before the main function.

Post a Comment

0 Comments