File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes char Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "char" Watch "char" New topic
Author

char

Priya Rajan
Greenhorn

Joined: Jul 06, 2001
Posts: 27
char c='\101';//there is no u after slash
what does it mean?
I think Characters can only be represented with hexadecimal numbers using \u. Am I right?
ex: char c='\u0000';
Pl explain
tvs sundaram
Ranch Hand

Joined: Jan 28, 2001
Posts: 153
Hi Priya,
Char literals are single quoted characters or unicode values (begin with \u).
HTH
Priya Rajan
Greenhorn

Joined: Jul 06, 2001
Posts: 27

Pl explain why this line is compiled? It is neither char nor unicode.
char c='\101'; //it prints some char also when printed.
I have exam tomorrow. Pl help
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
Wow - that is interesting. The '\101' seems to be interpreted as octal, resulting in 65 decimal = 'A'
It is actually in the Java Language Specification 3.10.4 but I never came across it before. Literal char examples given in the JLS are:
'a'
'%'
'\t' escaped tab char
'\\' escaped \ char
'\u03ad' unicode - interpret as Hex
'\uFFFF' unicode
'177' octal
plus a couple of examples with non-ascii characters.
Bill
[This message has been edited by William Brogden (edited July 29, 2001).]
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1167
According to William´┐Żs book, \xxx is a valid escape sequence.
It says in page 34, \xxx is a character in octal representation; xxx must range between 000 and 377.
Cheers,
Dan


William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: char
 
Similar Threads
setLength() ??
char examples
assignments and + operator
Characters
Convert char to unicode