Maruthi Krishna has Published 951 Articles

When and where static blocks are executed in java?

Maruthi Krishna

Maruthi Krishna

Updated on 30-Jul-2019 22:30:26

2K+ Views

A static block is a block of code with a static keyword. In general, these are used to initialize the static members. JVM executes static blocks before the main method at the time of class loading.Example Live Demopublic class MyClass {    static{       System.out.println("Hello this is a static ... Read More

Advertisements