Hi, Got this question from Mughal/Rasmussen:- Which of the following lines are valid declarations? Select all valid answers a) char a = '\u0061'; b) char \u0061 = 'a'; c) ch\u0061r a = 'a'; The answer says everything is valid. I can understand the logic behind the answer...you can replace any char with unicode equivalent..but i tried it in SunOne IDE and the compilation fails. Am i doing anything wrong? Thanks
Thanks Valentin and sorry about the name. I still am not sure how to compile it.. Is there anything i should be importing or setting to tell the compiler i am using unicode char? Thanks in advance.
I did a test program with the problem p. 33. The answer is correct Did you type in each line separately and compile it? If you type in all lines together it will try to redefine the literal which you can not do. Got It? Also, did you notice earlier in text about how Unicode is declared so char a = '\u0061' - p25. Character literal valid char \u0061 = 'a' - yep valid rewrite: char a = 'u0061' just replaced value - correct ch\u0061r a = 'a' - think \u0061 is an a right? So char a = 'a' - just replace the values. Understand the meaning of a literal and the assignment operator [ June 17, 2003: Message edited by: James Chegwidden ]
Mr. C<br /> <br />Author and Instructor<br />My book:<br /><a href="http://www.aw-bc.com/catalog/academic/product/0,1144,1576761614,00.html" target="_blank" rel="nofollow">http://www.aw-bc.com/catalog/academic/product/0,1144,1576761614,00.html</a>
I tried ,compilation was fine.But I didn't understand the logic fully.does JVM replaces unicode value with the equivalent unicode character during runtime? Thanks Veena
SCJP1.4
"Continuous effort - not strength or intelligence - is the key to unlocking our potential."
*Winston Churchill