I saw your posting earlier and thought somebody else would answer better than I can, but I shall try.
You know that \ is a sort of meta-character in Java strings; it "escapes" the character following. If I remember correctly there are about 8 escape combinations:
\t Tab (horizontal)
\n newline (or more precisely the line-feed character 0x0a)
\r return (the carriage return character 0x0d)
\f form feed
\' Single quote (not smart quotes)
\" Double quote (not smart quotes)
You can also insert a Unicode or octal character with an escape sequence like \u1234 or\123. So it is not at all surprising that Java will translate a backslash to \\. That is the normal Java way of writing backslash.
Originally posted by Campbell Ritchie: You know that \ is a sort of meta-character in Java strings; it "escapes" the character following.
Backslash is a special character in Java string literals (and char literals, too). That is, when you want to type a fixed string into your source code, you have to use backslash escape codes for some special characters (including backslash).
Once the characters are stored in a Java String object on the heap, the special meaning of backslash is gone. A backslash in a Java String object is just a backslash, nothing more. [ October 16, 2007: Message edited by: Peter Chase ]
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Joined: Oct 13, 2005
You have put it rather better than I did, Mr Chase.