This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi, I was looking the other day some mock exams for the programmer certification exam, and found a question asking if the fllowing is a legal assigment: char c1 = '\u000A'; I though it was valid, but I found that is not. But, the following is valid: char c1 = '\u000B'; So, my question is: Why is the first assigment invalid?
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'.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
Joined: Oct 18, 2007
Thanks for your answer!!! By the way, does somebody know if questions like this one is likely to appear in the java programmer certification exam? (Sorry, I know this second question might belong to a different thread).
Originally posted by Roberto S�nchez: ...does somebody know if questions like this one is likely to appear in the java programmer certification exam? (Sorry, I know this second question might belong to a different thread).
I think it could appear on the SCJP exam, but I don't know how likely this would be.
(We have a special forum for SCJP topics. You might try posting there.)