Skip to content

binimbabu/Java-static-block

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Static contexts

Lets take an example of real lifecase scenario In the Banking Application the accountBalance, withDraw() and checkBalance() are different for each customers, hence accountBalance, withDraw() and checkBalance() are non-static. But when the customer takes loan the interest and calculateInterest() are same among customers in a bank, hence interest and calculateInterest() are static.

static block

package staticBlock;

public class staticClass {

public static void main(String[] args) {

}

static {
	
}

}

anything mentioned in the static (here i.e static {}) whatever placed in the static block of code will be executed by the jvm when the class (here 'staticClass') will be loaded, even before the main class is called. The static block will be called only once when the class is loaded.

About

Java-static-block

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages