Saturday, March 10, 2007

The main Method


A method is a named block that can be called, and where program execution can continue. Other names for methods in non-object-oriented languages are functions and procedures. But unlike functions and procedures, methods are also members of a class.

The main method is a method that serves as a starting point for program execution. The main method is called automatically when program execution begins. You will get a runtime error if this method is missing.


1 package sharingjava;
3 public class Example {
5     public static void main(String[] args) {
6         System.out.println("Hello World!");
7     }
9 }


One more thing... It's impossible to know that your program need the main method just by examining the grammar. You will not find it there.

No comments: