This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Artima Forums.
Message:
Greetings for ANJAN frm SWAPNIL
Posted by swapnil on November 30, 2000 at 1:30 AM
> hi anjan, hello my friend, how are u? pl. find ur query solveed (?) . i tried my level best to explain ur query. if u want to include backslash then use double backslash to give u a single in the output. if u use single backslash in the program the compiler understands it as an escape sequence and tries to find the proper escape character after the single backslash. in ur case the compiler does not find any valid escape sequence (like \n or \t or \r etc) . so the compiler idiot is giving u an error. The code goes like this. .........................................................
class changline { public static void main(String[] args) { String s1="swapnil" +" singapore"; System.out.println(s1); String s2="tanata "+ "\n" + "in hongkong"; System.out.println(s2); /* String s3=" nichole \ " + " my life"; YOU CAN'T WRITE LIKE THIS */ String s4=" nichole \\ " + " my life"; System.out.println(s4); } } ........................................................ hope this helps regards, swapnil
Replies:
|