aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Character ranges Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Character ranges" Watch "Character ranges" New topic

Character ranges

Shafeeq Sheikh
Ranch Hand

Joined: May 12, 2000
Posts: 68
Hi guys....
char a = '\u000A';
gives a compiler error but
char a = '\u000B'; compiles cleanly......
Can't seem to figure out the correct range of a CHAR literal....
Can anybody throw some light on this???

Joined: Apr 21, 2000
Posts: 26
the problem that u seem to have is that the character '\u000a'
is reserved.
thats the reason that u cant assign it to anything else.
Ranch Hand

Joined: May 31, 2000
Posts: 116
Remember unicode escapes are processed before actual compilation.
Thus your code
char a = '\u000A';
char a = '
as \u000a is the new-line character

That is clearly an error.
Also check-out '\u0027' which is single-quote
char a = '\u0027';
char a = ''';
and '\u005c' which is back-slash.
char a = '\u005c';
char a = '\';

Shafeeq Sheikh
Ranch Hand

Joined: May 12, 2000
Posts: 68
Does this mean that one has to remember/memorize all of these codes so that questions of these types in the SCJP can be answered correctly???
That'll be tough!!!
It is sorta covered in the JavaRanch Style Guide.
subject: Character ranges