• 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

identifier name

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have typed this statement in eclipse

char \u0061 = �a�;

and it is not giving any error . But it has to give error because the identifier name is starting with "\" which is illegal, please give me explanation about this identifier naming.
 
Ranch Hand
Posts: 65
 
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
I think Ajay already understands what characters you can use in a variable name.

In Java source code, you can use Unicode escape sequences that look like \uNNNN where NNNN is the four-digit hexadecimal code of the character. These escape sequences are processed by the Java compiler as the very first step in the compilation process. Because of this, you can use an escape sequence in the place of a normal character.

Character 0061 is the lower case a. So

char \u0061 = 'a';

is exactly the same as:

char a = 'a';

You could even go further. Do you understand what the following line of code is?

\u0063\u0068\u0061\u0072\u0020\u0061\u0020\u003d\u0020\u0027\u0061\u0027\u003b
[ February 28, 2008: Message edited by: Jesper Young ]
reply
    Bookmark Topic Watch Topic
  • New Topic