0

Can we run program without main method in Java?

Java Question

10th Oct 2018, 3:20 AM
Pranav Deshmukh
Pranav Deshmukh - avatar
2 odpowiedzi
+ 4
If you wish to include Android apps, the code you write in Java does not have a main method. There still is one. It is just part of the supplied code libraries of the generic Android app. All programming languages must have some form of entry point to pick where they start running from. Java uses a main method. Python picks the first line of the source file. These things are fixed and can't be changed without rewriting the compiler or interpreter for the language.
10th Oct 2018, 5:46 AM
John Wells
John Wells - avatar
+ 4
According to my knowledge we cannot execute without a main method because when your running the java program. javaVirtual machine look for the main method.if JVM could not find the main method itwill show you run time error Exception in thread main could not find the mainclass.
10th Oct 2018, 5:25 AM
Love Barot
Love Barot - avatar