DEV Community

Anees Abdul
Anees Abdul

Posted on

Static/Non-Static Block

What is a Static Block:
It is a block of code that runs once when the class is loaded into memory, without creating object.

static{
//code}
Enter fullscreen mode Exit fullscreen mode

What is a Non Static Block:
It is a block that runs every time when an object is created.

{
//code
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)