Java's Character Literals
Character literals appear between single quote marks viz:
char c = 'a'; //make character variable c contain the letter 'a'
Certain special characters are represented by the following escape sequences (which are also placed between single quote marks in assignment statements).
|\n || new-line || \u000A
| \t || tab || \u0009
| \b || back-space || \u0008
| \r || return || \u000D
| \f || form-feed || \u000C
| \\ || back-slash || \u005C
| \' || single quote || \u0027
| \" || double quote || \u0022
| \ddd|| character's octal value || d = 0 to 7
| \udddd|| character's hexadecimal value|| d = 0 to F
String literals appear between double quote marks viz:
string s = "help"; /* make string variable s point to a string
array containing the letters 'help' */
To break a line within a quoted string, you must insert a \n into the string, not simply start a new line in your source file. Be careful of how you place octal character entities in strings. For instance:
\0116 is rendered as \t6 (ie a tab followed by a character 6)
\116 is rendered as N.
© 1998 Robert John Morton