Java printing multiple lines with a single statement

Question

We would like to print multiple lines with a single statement.

public class Main 
{
   // main method begins execution of Java application
   public static void main(String[] args)
   {
      //your code here
   } // end method main
} 



public class Main 
{
   // main method begins execution of Java application
   public static void main(String[] args)
   {
      System.out.println("Welcome\nto\nJava\nProgramming!");
   } // end method main
} 

Note

\n output new line characters.

Escape sequence Description
\n Newline.
\t Horizontal tab.
\r Carriage return.
\\ Backslash. Used to print a backslash character.
\" Double quote.



PreviousNext

Related