How did the methods inside the main method got executed despite the main method not being called? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How did the methods inside the main method got executed despite the main method not being called?

Is there an invisible line of code that calls main or something like that? EDIT: Sample code: public class Program {public static void main(String[] args) {System.out.print("Hello") } } /*The program outputs "Hello", despite the main method not being called.*/

13th May 2018, 1:48 PM
Ibaadi Jaya
Ibaadi Jaya - avatar
2 Answers
+ 22
where is the code ??? 🤔🤔🤔
13th May 2018, 1:56 PM
🌛DT🌜
🌛DT🌜 - avatar
+ 7
That's the only method called by the JVM, automatically.
13th May 2018, 2:19 PM
Dev
Dev - avatar