KEMBAR78
Main method in java | PPTX
Main method in Java
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[])
{
.......
.......
}
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.
Example of main method
public class mainclass
{
public static void main(String[] args)
{
System.out.println("I am from Main()");
}
}
Reference
http://www.tutorial4us.com/java/java-main-method

Main method in java

  • 1.
  • 2.
    Main method injava 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[]) { ....... ....... }
  • 4.
    Keywords used withmain 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.
  • 5.
    Example of mainmethod public class mainclass { public static void main(String[] args) { System.out.println("I am from Main()"); } }
  • 6.