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 Answers
+ 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