Declaring a Method
Line 6 is an end-of-line comment indicating the purpose of lines 7–10 of the program. Line 7 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. For a Java application, one of the methods must be called main and must be defined as shown in line 7. Methods perform tasks and can return information when they complete their tasks. Keyword void indicates that this method will not return any information. In line 7, the String[] args in parentheses is a required part of the method main’s declaration—we discuss this in Appendix E.
The left brace in line 8 begins the body of the method declaration. A corresponding right brace must end ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access