Originally posted by Moieen Khatri: Can some one please explain why a "\\" is used in a String to represent a "\"
That's because '\' is the escape character for character and string literals. It's used as a prefix for special characters, such as \n (newline), \t (tab), and \' (single quote). Most of these characters cannot appear directly within a literal.
Now, imagine that you want to print the sequence c:\too\noob. To do this, you can't just write "c:\too\noob" as a string literal in your Java program, since this will be interpreted as "c:" + (tab) + "oo" + (newline) + "oob". To get around this, you would use the sequence \\ to denote that you really do want a backslash character. Thus you'd write the string literal as "c:\\too\\noob".