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
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Character ranges" Watch "Character ranges" New topic
Author

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???
Thanks....
sushant
Greenhorn

Joined: Apr 21, 2000
Posts: 26
Hi,
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.
sushant
rajsim
Ranch Hand

Joined: May 31, 2000
Posts: 116
Remember unicode escapes are processed before actual compilation.
Thus your code
char a = '\u000A';
becomes
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';
means
char a = ''';
and '\u005c' which is back-slash.
char a = '\u005c';
means
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!!!
 
 
subject: Character ranges
 
Similar Threads
Why this output in this I/O program?
Operators
Reg. Casting rules
Difference between String.copyValueOf(char[]) and String.valueOf(char[])
Overloading and type conversion