0

Why Instance Initializer block is not executed ...??

I have been read Instance Initializer blocks are executed before constructor runs ... but if I didn't create any constructors and even I didn't create an object why Instance Initializer blocks are run .. 🤔😐 please explain why ...?? https://code.sololearn.com/cLI9cqh8VDyB/?ref=app

21st Apr 2021, 7:08 AM
❤☆Nani☆❤
❤☆Nani☆❤ - avatar
6 Antworten
+ 1
♡Nani♡ it will get called only if you create an instance of the class.. Program program = new Program();
22nd Apr 2021, 6:56 AM
durian
durian - avatar
+ 2
Please provide a link for this code.
21st Apr 2021, 7:11 AM
JaScript
JaScript - avatar
+ 2
This is a method and can be executed in main.
21st Apr 2021, 10:41 AM
JaScript
JaScript - avatar
+ 1
cause jvm doesnt create an instance of the program class..it just simply call the static main method prob what u want is static initialization block
21st Apr 2021, 7:37 AM
durian
durian - avatar
+ 1
Lily Mea no I am talking about normal instance blocks
21st Apr 2021, 10:01 AM
❤☆Nani☆❤
❤☆Nani☆❤ - avatar
0
Lily Mea thanks 😊
22nd Apr 2021, 10:13 AM
❤☆Nani☆❤
❤☆Nani☆❤ - avatar