0

They said every Java program has to include the "main" (String [] arg); why must it be included in any java program?

22nd Jul 2016, 7:06 AM
Mazala
6 Antworten
+ 4
Like playing football, we need a point to start the game.
22nd Jul 2016, 8:50 AM
WPimpong
WPimpong - avatar
+ 3
(string[] arg);is to included to read the command line arguments
22nd Jul 2016, 11:30 AM
Ravi Teja
Ravi Teja - avatar
+ 3
main (String []args) is defined as the proper declaration of main statement. However, in general use when your main statement is not being used to declare a proper class object, then simply main() can be used. It can also be parameterized. However some compilers only run the main method when it is properly declared, ie the one u mentioned above. A main method is not compulsory. But the compiler in this app needs the proper main statement as it cannot create an object of the class like bluej etc. so it is necessary here.
22nd Jul 2016, 4:06 PM
Rich
Rich - avatar
+ 2
this is method from which program start
22nd Jul 2016, 3:42 PM
Ivan Kavatsiv
Ivan Kavatsiv - avatar
+ 2
Java program run on JVM. JVM is a program. And it has been written to run java program by starting from main method. So if you dont have main, your java program cannot be run(by JVM).
23rd Jul 2016, 12:35 AM
WPimpong
WPimpong - avatar
+ 1
first thing program execution start with main so it is necessary to have a main method in every program and second thing execution of program is performed by JVM which is a program written in c language when it runs program it searches for the main method and the syntax public static void main(string []args) if it does not find this syntax program yields error you can change the order of words in main method like static void public main (string []args) so we can say JVM searches for these words only in main method order doesn't matter you can check
5th Aug 2016, 6:44 AM
sachin tomar
sachin tomar - avatar