Downloaded 71 times

![Main method in java
Main() method is starting execution block of any java
program. If any java class contain main() method
known as main class.
Syntax
public static void main(String args[])
{
.......
.......
}](https://image.slidesharecdn.com/mainmethodinjava-150926005319-lva1-app6892/75/Main-method-in-java-2-2048.jpg)

![Keywords used with main method
• Public: main method is preceded by public
keyword it means main method scoop is
available anywhere in java program.
• Static: memory allocated for main method
only once.
• Void: nothing return
• String args[]: String array used to hold
command line arguments in the form of String
values.](https://image.slidesharecdn.com/mainmethodinjava-150926005319-lva1-app6892/75/Main-method-in-java-4-2048.jpg)
![Example of main method
public class mainclass
{
public static void main(String[] args)
{
System.out.println("I am from Main()");
}
}](https://image.slidesharecdn.com/mainmethodinjava-150926005319-lva1-app6892/75/Main-method-in-java-5-2048.jpg)

The main method in Java is the starting execution block of any Java program, defined as 'public static void main(String[] args)'. It utilizes the keywords public, static, and void to specify accessibility, memory allocation, and return type, respectively. The document also includes an example of a main method within a Java class.