To create a static block in a Java program, we use a keyword static. If we want to execute any program before the main method, the program should be written inside the static block. The static block is used when you want to perform initialization or any other preparatory actions like connecting to the database or remote serer before accessing a targeted class.

As you can see in the console after executing the code, the instructions written inside the static block has been executed first and then the main method has been executed. It's a very simple concept in Java. I am using Eclipse IDE for learning Java currently.
Hello @leoumesh, thanks for sharing your learning experience using Eclipse IDE. Your skills are what we encourage in our community.
Your post has been curated with @gitplait community account because this is the kind of publications we like to see in our community.
Join our Community on Hive and Chat with us on Discord.
[Gitplait-Team]