64 Introduction to (Web hosting domain) Java Applications Chapter 2 two

64 Introduction to Java Applications Chapter 2 two characters and nare not printed on the screen. The backslash () is called an escape character. It indicates that a special character is to be output. When a backslash appears in a string of characters, Java combines the next character with the backslash to form an escape sequence. The escape sequence nis the newline character. When a newline character appears in a string being output with System.out, the newline character causes the screen s output cursor to move to the beginning of the next line in the command window. Some other common escape sequences are listed in Fig. 2.5. 1 // Fig. 2.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( String args[] ) 8 { 9 System.out.println( “WelcomentonJavanProgramming!” ); 10 11 } // end method main 12 13 } // end class Welcome3 Welcome to Java Programming! Fig. 2.4Printing multiple lines of text with a single statement. Fig. 2. Escape sequence Description n t r \ ” Newline. Position the screen cursor to the beginning of the next line. Horizontal tab. Move the screen cursor to the next tab stop. Carriage return. Position the screen cursor to the beginning of the current line; do not advance to the next line. Any characters output after the carriage return overwrite the characters previously output on that line. Backslash. Used to print a backslash character. Double quote. Used to print a double-quote character. For example, System.out.println( “”in quotes”" ); displays “in quotes” Fig. 2.5Some common escape sequences. Fig. Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/2/01
Note: If you are looking for best quality webspace to host and run your tomcat application check Vision shared web hosting services

Leave a Reply