How many times static block executed? And when its execute? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 13

How many times static block executed? And when its execute?

10th Jun 2017, 12:18 AM
B Karthik Marimuthu
B Karthik Marimuthu - avatar
5 Answers
+ 24
with respect to Java static block executes when you run a program after initializing the static variables, it executes only once! if you want to repeat it, declare it as a static method.. and of course! call it...
12th Jun 2017, 7:27 AM
Ruthresh kumar R
Ruthresh kumar R - avatar
+ 10
its possible to use more than one static block? #Rrestoring faith
10th Jun 2017, 3:08 PM
B Karthik Marimuthu
B Karthik Marimuthu - avatar
+ 8
OK, its clear for me.. thanks
12th Jun 2017, 9:29 AM
B Karthik Marimuthu
B Karthik Marimuthu - avatar
+ 5
Once when class loads (before main is called).
10th Jun 2017, 12:23 AM
Rrestoring faith
Rrestoring faith - avatar
0
Can you elaborate your question a little more?
10th Jun 2017, 12:23 AM
Ulisses Cruz
Ulisses Cruz - avatar