• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

char

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic