Diapositiva 1 · So, for Java, double quotes and apostrophes have a special meaning. To use them as...
Transcript of Diapositiva 1 · So, for Java, double quotes and apostrophes have a special meaning. To use them as...
System.out.println(“Hello World!”);
• double quotes “ ” to show the start and end of your message.
System.out.println(“Hello World!”);
• What if I want to use them as part of my message?
“Hello World!”
So, for Java, double quotes and apostrophes have a special meaning.
To use them as part of your message you have to use escape sequences.
System.out.println (" \"Hello World!!\" ");
Escape Sequence
Name Description
\n New line Takes the cursor to the beginning of the next line e.g. System.out.println(“\n Welcome”);
\t Horizontal tab
Takes the cursor to the next tab stop e.g. System.out.println(“\t Welcome”)
\” Double quote
Displays a quotation mark (“)
\’ Apostrophe Displays an apostrophe (‘)
Code User Screen
System.out.print(‘G’) G
System.out.print(5) 5
System.out.print(2016) 2016
• Text that is not part of your code but serves as a guide when trying to figure out what the lines of your program mean.
• You can write anything you wish inside comments.