The main() Method

The main() method is used as the entry point for a Java application program. All application programs must have a main() method. The main() method is a method of the class that is executed to run the program.

NOTE

Importing java.lang The java.lang package is always imported by default and does not need to be imported by an import statement.

For example, if your program's name is MyProgram, then the MyProgram class must be defined in a file named MyProgram.java. The MyProgram class must have a correctly defined main() method.

NOTE

Method Modifiers The static modifier identifies that a method applies to a class as a whole and not to a specific instance of a class (that is, an object). The public modifier identifies that a method ...

Get Sun Certification Training Guide (310-025, 310-027): Java™ 2 Programmer and Developer Exams now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.