Java Reference
In-Depth Information
Programmers note:
One of the most common mistakes made by beginning Java program-
mers is to use a different name for the file and the driving class. You
must also be careful to use identical capitalization in the file name and
the class name.
The left-hand roster symbol indicates the beginning of the class named
HelloJava. At the end of the program listing there is a right-hand roster
symbol that terminates the HelloJava class.
The next statement in the HelloJava program creates a method named
main(). Java code must always be contained in a method. The main()
method is created as follows:
public static void main(String[] args)
{
Every Java program must have a method named main. The words pub-
lic, static, and void are Java keywords that determine the characteristics
of the main method. Static indicates that the method remains active at all
time that is, that it “stays.” Void indicates that main returns nothing to the
operating system. The element inside parentheses represent a string
typed by the user when the program is executed. This string is sometimes
called the command tail . Command tails are seldom used in Java pro-
gramming.
Incidentally...
We use parentheses following the name of methods to make them eas-
ier to identify. Hereafter, the method named main appears as main().
This is a common style followed by many programming topics.
Program execution always starts at the main() method of the Java
class that drives the application, that is, the class that has the same name
as the application's source file.
The left-hand roster indicates the beginning of the main() method.
Later in the listing you can see a right-hand roster that marks the end of
main() . The following statement is included in main():
System.out.println(“Hello World, this is Java”);
}
}
Search WWH ::




Custom Search