Displaying a Single Line of Text with Multiple Statements

Welcome to Java Programming! can be displayed several ways. Class Welcome2, shown in Fig. 2.3, uses two statements (lines 9–10) to produce the output shown in Fig. 2.1. [Note: From this point forward, we highlight with a yellow background the new and key features in each code listing, as we’ve done for lines 9–10.]

 1   // Fig. 2.3: Welcome2.java 2   // Printing a line of text with multiple statements. 3  4   public class Welcome2 5   { 6      // main method begins execution of Java application 7      public static void main(String[] args) 8      { 9         System.out.print("Welcome to ");        10         System.out.println("Java Programming!");11      } ...

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.