|
EscapeDemo |
|
1 // Example 8.1 joi/examples/EscapeDemo.java 2 // 3 // 4 // Copyright 2003 Bill Campbell and Ethan Bolker 5 6 // A class illustrating the escape character '\' in quoted Strings 7 // 8 // %> java EscapeDemo 9 // argument to println output 10 // "hello world" hello world 11 // "hello\nworld" hello 12 // world 13 // "\"hello world\"" "hello world" 14 // "hello\tworld" hello world 15 // "hello\bworld" hellworld 16 // 17 // Note the use of quotes to get embedded blanks. 18 19 public class EscapeDemo 20 { 21 public static void main( String[] args ) 22 { 23 System.out.println("argument to println\toutput"); 24 25 System.out.print("\"hello world\"\t\t"); 26 System.out.println("hello world"); 27 28 System.out.print("\"hello\\nworld\"\t\t"); 29 System.out.println("hello\nworld"); 30 31 System.out.print("\"\\\"hello world\\\"\"\t"); 32 System.out.println("\"hello world\""); 33 34 System.out.print("\"hello\\tworld\"\t\t"); 35 System.out.println("hello\tworld"); 36 37 System.out.print("\"hello\\bworld\"\t\t"); 38 System.out.println("hello\bworld"); 39 } 40 } 41
|
EscapeDemo |
|