Presentation is loading. Please wait.

Presentation is loading. Please wait.

Escape sequences escape sequence: A special sequence of characters used to represent certain special characters in a string. \t Inserts a tab in the.

Similar presentations


Presentation on theme: "Escape sequences escape sequence: A special sequence of characters used to represent certain special characters in a string. \t Inserts a tab in the."— Presentation transcript:

1 Escape sequences escape sequence: A special sequence of characters used to represent certain special characters in a string. \t Inserts a tab in the text at this point. \n Inserts a newline in the text at this point. \" Inserts one double quote in the text at this point. \’ Inserts one single quote in the text at this point. \\ Inserts a backslash character at this point \r Moves cursor to start of line/overwrites as it types \b Inserts a backspace at this place Example: System.out.println("\\hello\nhow\tare \"you\"?\\\\"); Output: \hello how are "you"?\\

2 Question How many visible characters does the following println statement produce when run? System.out.println("\t\nn\\\t\"\tt"); 1 2 3 4

3 Practice Program 1 What sequence of println statements will generate the following output? This program prints the first lines of the song "slots". "She lives in a trailer" "On the outskirts 'a Reno" "She plays quarter slots in the locals casino."

4 Practice Program 2 What sequence of println statements will generate the following output? A "quoted" String is 'much' better if you learn the rules of "escape sequences." Also, "" represents an empty String. Don't forget to use \" instead of " ! '' is not the same as "

5 Practice Program 3 What is the output of the following println statements? System.out.println("\ta\tb\tc"); System.out.println("\\\\"); System.out.println("'"); System.out.println("\"\"\""); System.out.println("C:\nin\the downward spiral"); 5

6 Answer to Practice Program 3
Output of each println statement: a b c \\ ' """ C: in he downward spiral

7 Practice Program 4 Write a println statement to produce this output:
/ \ // \\ /// \\\

8 Answer to Practice Program 4
println statement to produce the line of output: System.out.println("/ \\ // \\\\ /// \\\\\\");

9 Internet Transfer Project
To whom was the Internet oversight transferred (instead of the USA)? What entities (nations represented, companies represented, others) make up the group to whom the transfer was made? Who is responsible for the transfer? When did the transfer occur? What are the expected or potential changes in internet/information and use (positives and negatives)?


Download ppt "Escape sequences escape sequence: A special sequence of characters used to represent certain special characters in a string. \t Inserts a tab in the."

Similar presentations


Ads by Google