• 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 value assignment

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
char c='\u000A'
char c='\u000D'.
how the above two are invalid constants.
please can anyone explain this.
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Given that java code can be written in unicode, the Lexical Translation is applied to all java code at compile time so you can use unicode identifiers etc using only ASCII characters. So before a file is compiled all '\uxxxx' occurences in the file will be translated into their unicode equivalent. If you check out an ASCII table, you will find that chars 10 (\u000A) and 13 (\u000D) are line feed and carriage return respectively, so a new line will start straight after these tokens (I doubt you will see this in the exam).

The code

will be translated into

which of course won't compile.
[ May 01, 2006: Message edited by: Kristian Perkins ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic