1
2Static Block:
3 used for initializing statics members,
4it belongs to the class and only one copy
5and runs only once and before everything
6
7I use it in configuration.reader class
8 in my framework
1The static keyword in Java is used for memory management mainly. We can apply static keyword with
2variables, methods, blocks and nested classes. The static keyword belongs to the class
3 than an instance of the class.
4
5The static can be:
6
7Variable (also known as a class variable)
8Method (also known as a class method)
9Block
10Nested class
1static keyword is a non-access modifier. static keyword can be used with
2class level variable, block, method and inner class or nested class.
1It is used to create another block before the main class.
2 every java codes runs here first.
3 Any code gets executed before the main class
4
5 static{
6 //code is placed between these brackets.
7 }
1Static Block:
2 used for initializing statics members,
3it belongs to the class and only one copy
4and runs only once and before everything
5
6I use it in configuration.reader class
7 in my framework
1// to create static block in java
2static{
3 // code to be executed is placed here
4}
5
6// its placed inside class. its executed whenever the class is created not when its object is created or called.