3.4 The void main method

Previous Index Next 


When the Java runtime is run a class name must be supplied to it as a parameter. This is the class that the Java runtime will execute. By definition the Java runtime will look for a specific method in the class and start execution from there.

This method is the void main method of the class. This method must be declared as follows:

public static void main(String[] args)
 
For instance:
public class StartClass
 {
    public static void main(String[] args)
      {
        // .... code goes here
      }
 }

The public and static method modifiers will be explained later in the guide.