Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

float f= \u0038

 
weiliu lili
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why this is valid? float f= \u0038
I thought the right way should be float f= 'u0038'
the explanation is that \u0038 is unicode for nbr 8. what does that mean?
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can read more about Unicode in the JLS, §3.10.4 Character Literals. In short, Unicode format encapsulates all characters in the World, unlike ASCII.
When you compile a Java program, Unicode characters are translated very early in the process. Therefore, when it actually came time to compile that code, the compiler would see the line:

This is obviously valid. Of course, had we put tick marks around it, we would have ended up with this:

This is also legal, but it's also quite different. The number 8 and the character value of the number 8 are not one in the same.
I hope that helps,
Corey
[ June 06, 2002: Message edited by: Corey McGlone ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic