The Main Method

5.7 The Main Method

A Java application has to start somewhere. That somewhere is the main method. When you run a Java application, the Java interpreter looks for a main method in the class and runs it. You should declare the main method the main method as follows:
public static void main(String args[])
There are a couple of differences between this method declaration and the other method declarations in the Newton class . Here are the differences:
Java provides a way to control access to the methods and variables in a class. If a method is declared public, the Java interpreter will allow methods from any class to call it. You can think, for now, that the default is to allow a method to be called only by other methods in the same class.
The return type void indicates that the method has no return value.
String args[]
The main method takes an array of strings as an argument. You will learn more about this argument when we discuss command-line parameters.

In our Newton's method code, the main method contains all the interesting code, and we are going to look at the body of the code next.

David Maxwell, who is still writing this, would like to hear your comments and suggestions.