• 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
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

char examples

 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are some obscure examples of a char value?
char Test = 'p';
char Test2 = 23;
I'd like to know how wierd this data type can look on an exam question....
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The following ones are valid too...
char uni = '\u0065';
char hex = 0x65;
char oct = 056;
but
char lf = '\u000a';
is not valid because this is actually a linefeed which is translated as a real linefeed in a very early stage during the parsing and the line ends up looking like
char lf = '
';
which is clearly not a valid Java statement.
 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not sure if I exactly got what u are asking. But if u want to know what kind of values char datatype can hold...
Here are some,
char c;
Acceptable Values : Character Literals,Integer Literals which are within the range of values a char can hold
c='a';
c=0;
c=65535;
c=07;
c=0x07;
c='\u0061';
char c\u0061='\u0061';
Not acceptable:
c=-1; out of range for char
c=65536; out of range for char
 
Mike Cunningham
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks,
That's exactly the type of info I was looking for.
- Mike
 
reply
    Bookmark Topic Watch Topic
  • New Topic