Declaring a Method

Line 6

// main method begins execution of Java application

is an end-of-line comment indicating the purpose of lines 7–10 of the program. Line 7

public static void main(String[] args)

is the starting point of every Java application. The parentheses after the identifier main indicate that it’s a program building block called a method. Java class declarations normally contain one or more methods. For a Java application, one of the methods must be called main and must be defined as shown in line 7; otherwise, the Java Virtual Machine (JVM) will not execute the application. Methods perform tasks and can return information when they complete their tasks. We’ll explain ...

Get Java™ How To Program (Early Objects), Tenth Edition 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.