is a method called main compulsory for java programs? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

is a method called main compulsory for java programs?

8th Dec 2016, 5:21 AM
Sourav Mandal
Sourav Mandal - avatar
5 Answers
+ 2
well... not sure what you call compulsory, but it's where you call all your classes, and where you can create objects from your classes. The Main is where you test all your code!
8th Dec 2016, 5:27 AM
Nahuel
Nahuel - avatar
+ 2
In programming languages with different modules, there exists a starting point named main. It can be called function or a module. It is compulsory and it is the module executed at the very first.
15th Dec 2016, 5:28 PM
Rohit thapliyal
Rohit thapliyal - avatar
+ 1
Yep. The JVM has to start somewhere in the program, so when it starts running, it searches for the main method and works from there.
8th Dec 2016, 5:30 AM
DaemonThread
DaemonThread - avatar
+ 1
yes it is necessary for main class of the project
8th Dec 2016, 6:55 AM
Sandeep Chatterjee
0
There's some kind of Code, you actually don't need to "start" with the main method when writing it. But later in the code it's has to come in to be able to call the object's and classes. So whether it's written in the beginning or not the Main Method has to be present.
21st Dec 2016, 5:48 AM
Eremie Gillowei
Eremie Gillowei - avatar