• 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

problem with compiler's no problem:-(

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why no compiler error?
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
because if you want to write a number in hex it must start with 0x
so, char c=0x0005c; is a valid assignment because you're assigning the Hexidecmal 5c-th character "\" to the variable c.
but char c=5c; is not a valid assignment because it expects a decimal number, and of course you and I know that c is not a decimal digit
So, there are 4 possible ways to write this statement:
char c = 0x005c; (using hex)
char d = 92; (using decimal
char e = 0134; (using octal)
char f = '\\'; (using the character itself)
[ February 19, 2004: Message edited by: Jessica Sant ]
 
Harvinder Singh
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jessica,
Thanks for the crystal clear reply. I think the 0 after the 0x
are removed.because a hexadecimal could be of 4 digit only.I think If will will do this then a error will occur(I haven't compiled it...dont have JDK in the cafe).If I am wrong do correct me.

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic