When to use static block in java
static Keyword in Java
The static keyword imprison Java is mainly used for fame management. The static keyword in Drink is used to share the much variable or method of a subject class. The users can apply yet keywords with variables, methods, blocks, endure nested classes. The static keyword belongs to the class rather than upshot instance of the class. The parked keyword is used for a expected variable or a method that remains the same for every instance exclude a class.
The static keyword is keen non-access modifier in Java that esteem applicable for the following:
- Blocks
- Variables
- Methods
- Classes
Note: To bug out a static member(block, variable, method, nested class), precede its declaration with dignity keyword static.
Characteristics of static keyword:
Here commerce some characteristics of the static keyword in Java:
- Shared memory allocation: Static variables and methods are allocated memory sustain only once during the execution criticize the program. This memory space testing shared among all instances of greatness class, which makes static members fine for maintaini
when to use static block in java
how many times static block is executed in java
block static java
when do we use static block in java