why is the static block executed before the main method in java? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

why is the static block executed before the main method in java?

for instance: class A{ static{ //👈 system.out.print(1); } public static void main(String[] args){ sytem.out.print(2); } } //output is 12

16th Dec 2019, 10:24 PM
ᎯᏰᏰᎯ__ᏥᎿᏩ➰
ᎯᏰᏰᎯ__ᏥᎿᏩ➰ - avatar
0 Answers