File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes variable in comments! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "variable in comments!" Watch "variable in comments!" New topic
Author

variable in comments!

ashok khetan
Ranch Hand

Joined: Jul 29, 2001
Posts: 153
hi!
can u pl explain why does the code given below not compile? If we change the statement in main with //char a = '\u000B'; then it compiles fine. I couldn't understand both.

ashok.
__________
class MyClass {
public static void main(String args[]) {
//char a = '\u000A';
}
}
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
This was taken for the JLS 3.10.4 section
Because Unicode escapes are processed very early, it is not correct to write '\u000a' for a character literal whose value is linefeed (LF); the Unicode escape \u000a is transformed into an actual linefeed in translation step 1 (�3.3) and the linefeed becomes a LineTerminator in step 2 (�3.4), and so the character literal is not valid in step 3. Instead, one should use the escape sequence '\n' (�3.10.6). Similarly, it is not correct to write '\u000d' for a character literal whose value is carriage return (CR). Instead, use '\r'.


SCJP2. Please Indent your code using UBB Code
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: variable in comments!