Main Method | Heaton Research

Main Method

Get the entire book!
Java for the Beginning Programmer

The main method is where your program begins execution. The main method must be declared in a very strict format. The following shows how the main method should look.

public static void main(String args[])
{
// put main method actions here
}

Here you can see the main method being declared. The main method is public, so that everything can access it. Whenever you create a main method, which is once for every one of your Java applications, you should copy this main method header. There is little you can change about it. You will learn the exact meaning of the other parts of the main method when we study methods, in Chapter 6.

Copyright 2005-2008 by Heaton Research, Inc.