0
They said every Java program has to include the "main" (String [] arg); why must it be included in any java program?
6 odpowiedzi
+ 4
Like playing football, we need a point to start the game.
+ 3
(string[] arg);is to included to read the command line arguments
+ 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.
+ 2
this is method from which program start
+ 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).
+ 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