File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes character assignment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "character assignment" Watch "character assignment" New topic
Author

character assignment

Geethakrishna Srihari
Ranch Hand

Joined: May 25, 2005
Posts: 30
Please explain how assignment to character takes place:

char cf = '\101'; works fine....
what does it signify?

But char c = '\1001' ; gives compilation error.

if we assign unicode, why '\u00001' gives error even though it equals '\u0001'?
Erik Larson
Greenhorn

Joined: Apr 25, 2005
Posts: 10
'\101' is an octal representation of a number. The largest printable character is 255 decimal, or 377 octal. What is interesting is that if you assign the decimal value of '\1001' (513) to a char, that will print '?'. Why that is, I don't know. As for the unicode values, they must be exactly 4 hex digits.

'\101' == 0101 == '\u0041' == 0x41 == 65 == 'A'
[ May 25, 2005: Message edited by: Erik Larson ]

SCJP<br />SCJD - someday!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: character assignment
 
Similar Threads
Terenary operator
Converting a String to a Collection
primitive char and unicode value assignments
Unicode representation of a character
why char c='\u000a'; is not compiling?