Thursday, March 10, 2005

Escape Sequence

Escape Sequence
Escape Sequence Unicode escape Comment
\b \u0008 backspace, BS
\t \u0009 horizontal tab, HT
\n \u000a linefeed, LF
\f \u000c form feed, FF
\r \u000d carriage return, CR
\" \u0022 double quote, "
\' \u0027 single quote, '
\\ \u005c backslash, \
Octal Escape \u0000 to \u00ff from octal value

class EscapeSequence {
    public static void main(String[] args) {
        // character
        System.out.println('a');

        // Unicode character
        System.out.println('\u0061');

        // tab
        System.out.println('\t' + "tab");
    }
}
[user]$ javac EscapeSequence.java
[user]$ java EscapeSequence
a
a
        tab

No comments: