This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
when we compile the java file the source is converted from default encoding to unicode. At that time unicode chars like \Uxxx are replaced with the corresponding character. After that the source file is compiled. Here \u000a is a new line character like '\n'.
so String newline="\u000A" would be replaced like below newline=" ";
So compiler shows the error message unclosed string literal
Raghu J<br />SCJP 1.4<br /> <br />The Wind and waters are always<br />on the side of the ablest navigators.<br /><a href="http://groups.yahoo.com/group/scjp_share" target="_blank" rel="nofollow">SCJP Group</a><br /><a href="http://groups.yahoo.com/group/JavaBeat_SCWCD" target="_blank" rel="nofollow">SCWCD Group</a>
Joined: Jun 26, 2005
Unicode escape characters, of the form '\Uxxxx', where xxxx is a hexadecimal value, are processed very early in the translation process (See JLS ?3.10.4). As a result, the special characters '0A', line feed and '0D', carriage return are interpreted literally as 'end of line'. The expression:
char A = '\u000A';
char A =;
which results in a compile-time error. To avoid this error, always use the special escape characters '\n' (line feed) and '\r' (carriage return);