This week's book giveaway is in the Testing forum.
We're giving away four copies of Data Structures the Fun Way: An Amusing Adventure with Coffee-Filled Examples and have Jeremy Kubica on-line!
See this thread for details.
  • 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

can byte literal be a character literal

 
Ranch Hand
Posts: 118
Android Objective C Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi

as per my knowledge characters literals can be in 4 ways

char ch = 'a';
char ch = 97;
char ch = '\uxxxx'
char ch = 'any of the 8 escape characters';

here my doubt is since character literals take unicode value and unicode representation and display the corresponding character in the console output, when i am using unicode values and unicode representation in integral literals its not giving me any error. cause as per my knowledge integral literals can be of

Decimal
Octal
Hexadecimal

the reason being

int d = 'a';

s.o.p(d);

this is not giving me an error but instead displaying the unicode value i.e. 97

similarly

int d = '\uFace';

s.o.p(d);

this is giving me 64206 instead of an error



 
Bartender
Posts: 2236
63
IntelliJ IDE Firefox Browser Spring Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The value of char type is just a number (0 - 65535).
It can always be assigned to int variable.
 
Marshal
Posts: 76860
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can also denominate them in binary (Java7+).
 
You have to be odd to be #1 - Seuss. An odd little ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic