• 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
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Doubt for char in K&B

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have a doubt in charater literal.

if i am using the literal which is assigned to char, what will be the impact.

For example:

char c=(char)897; //in K&B book specfies it legal

this code is compiling fine. printing as "?"(question mark).

How can i use the literal which should be assigned in char.

Regards,
Shankar
 
Ranch Hand
Posts: 1609
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Shankar Selvaraju:

if i am using the literal which is assigned to char, what will be the impact.

....How can i use the literal which should be assigned in char.



Shankar, how do you understand the term "literal"? you think it as integer or character or....?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The char data type in Java represents a 16-bit Unicode character. To display any Unicode character, you need to use a font that contains the character. What operating system are you using? The font that Windows uses in the command prompt window does not contain the full set of Unicode characters. If you try to display a character which is not in the font, it will display a "?".

By the way, I looked up character 897 (code point U+0381) on the Unicode website, and this code point is empty - there is no character assigned to that particular code.
 
Shankar Selvaraju
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As per my understanding literal means value which is to be assigned to the respective char ot int etc...

Normally for char it will agree for unsigned 16 bit range(0 to 65535).
My doubt is i am assigning number literal to a char...see the above code.

While compliing the code no error is coming.

result is ?.
 
Shankar Selvaraju
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes Jesper,

i got it.

Thanks
 
reply
    Bookmark Topic Watch Topic
  • New Topic