Displaying Multiple Lines of Text with a Single Statement

A single statement can display multiple lines by using newline characters, which indicate to System.out’s print and println methods when to position the output cursor at the beginning of the next line in the command window. Like blank lines, space characters and tab characters, newline characters are white-space characters. The program in Fig. A.4 outputs four lines of text, using newline characters to determine when to begin each new line.

 1   // Fig. A.4: Welcome3.java 2   // Printing multiple lines of text with a single statement. 3  4   public class Welcome3 5   { 6      // main method begins execution of Java application 7      public static void main( ...

Get Android™ How to Program, Second 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.