Leo Umesh avatar

JAVA LESSON 3: LEARNING STATIC BLOCK

leoumesh

Published: 19 Jun 2020 › Updated: 19 Jun 2020JAVA LESSON 3: LEARNING STATIC BLOCK

JAVA LESSON 3: LEARNING STATIC BLOCK

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.

Screenshot_1.png

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.

Leave JAVA LESSON 3: LEARNING STATIC BLOCK to:

Written by

I am just a passionate blogger.

Read more #hive-174578 posts


Best Posts From Leo Umesh

We have not curated any of leoumesh's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From Leo Umesh