answersLogoWhite

0

The Main method is the method in which execution to any java program begins.

A main method declaration looks as follows:

public static void main(String args[]){

}

The method is public because it be accessible to the JVM to begin execution of the program.

It is Static because it be available for execution without an object instance. you may know that you need an object instance to invoke any method. So you cannot begin execution of a class without its object if the main method was not static.

It returns only a void because, once the main method execution is over, the program terminates. So there can be no data that can be returned by the Main method

The last parameter is String args[]. This is used to signify that the user may opt to enter parameters to the java program at command line. We can use both String[] args or String args[]. The Java compiler would accept both forms.

User Avatar

Wiki User

15y ago

Still curious? Ask our experts.

Chat with our AI personalities

ProfessorProfessor
I will give you the most educated answer.
Chat with Professor
EzraEzra
Faith is not about having all the answers, but learning to ask the right questions.
Chat with Ezra
JudyJudy
Simplicity is my specialty.
Chat with Judy
More answers

the main method in java tells the JVM from where to start execute the program

User Avatar

Wiki User

14y ago
User Avatar

User defined

User Avatar

Wiki User

12y ago
User Avatar

Add your answer:

Earn +20 pts
Q: What is the use of main method in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp