This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

char

 
Priya Rajan
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Priya,
Char literals are single quoted characters or unicode values (begin with \u).
HTH
 
Priya Rajan
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic