aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Valid char values! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Valid char values!" Watch "Valid char values!" New topic
Author

Valid char values!

fethi makhlouf
Ranch Hand

Joined: Feb 16, 2004
Posts: 50
Hello
i thought i am well prepared for the exam, but when i met that example, i undrestood i am not yet!
public class Test002 extends Super
{
public static void main(String args[])
{
char c1 = '\u00AA';
char c2 = '\u00DD';
char c3 = '\u000D';
char c4 = '\u000A';
}
}

can somone tell me why c1 and c2 are valid values wheras c3 and c4 are not!
Thank you in advance!


SCJP 1.4
Bijesh Krishnadas
Ranch Hand

Joined: Aug 08, 2002
Posts: 31
Originally posted by fethi makhlouf:

char c2 = '\u00DD';
char c3 = '\u000D';
char c4 = '\u000A';
}
}

can somone tell me why c1 and c2 are valid values wheras c3 and c4 are not!

Firstly,
/u000d represents carriage return
/u000a represents new line
Now the first thing that the compiler does is convert the unicode into the respective characters. This happens, I guess, even before the actual compilation process starts.
So the c3 and c4 lines when passed to the compiler would look like this

So ur code above is equivalent to the one below:

and hence the compile error.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Valid char values!