• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Character ranges

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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....
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!!!
 
What a show! What atmosphere! What fun! What a tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic