JAVA LESSON 3: LEARNING STATIC BLOCK

in Popular STEM4 years ago

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.

Sort:  

Hi , am really interested in javascript and programming. Who be nice if you put links to your previous lessons in your new posts.

Thanks for sharing

Coin Marketplace

STEEM 0.28
TRX 0.12
JST 0.033
BTC 71148.50
ETH 3780.07
USDT 1.00
SBD 3.78