A.3 Modifying Your First Java Program

Welcome to Java Programming! can be displayed several ways. Class Welcome2, shown in Fig. A.3, uses two statements (lines 9–10) to produce the output shown in Fig. A.1.

Fig. A.3 Printing a line of text with multiple statements

Computer code and output. The code has 12 lines.

The program is similar to Fig. A.1, so we discuss only the changes here. Line 2 is a comment stating the purpose of the program. Line 4 begins the Welcome2 class declaration. Lines 9–10 of method main display one line of text. The first statement uses System.out’s method print to display a string. Each print or println statement resumes displaying characters ...

Get Android How to Program, 3/e 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.