• 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 representation

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello friends,
char c = '\101';
The author says 101 is an octal number and it is valid. Can I give octal numbers? If so, what is the valid range?
char c = '\u0001' ; what does \u means in this code? (unicode?)
Thanks
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Priya,
Yes you can give octal numbers to characters. Since the octal value represents 3 bits and a char has 16 bits the range will be:
000000
077777
Since 7 is the largest possible octal value.
The '\ ' form is exactly the same as using 0 in front of the number.
The same goes for '\u '. The \u tells the compiler that the following digits (max = 4) will be for a unicode character instead of a regular string.
In java, when the compiler sees a single quote (') it only allows a single element until another single quote is required. By using the escape (\) element we can have more elements inside of single quotes.
Regards,
Manfred.
 
Brace yourself while corporate america tries to sell us its things. Some day they will chill and use tiny ads.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic