This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Java in General and the fly likes Unicode Representation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Unicode Representation" Watch "Unicode Representation" New topic
Author

Unicode Representation

sr shashidhar
Greenhorn

Joined: Jan 17, 2013
Posts: 27
Hi frnds,






My question is how we are getting 8 and 56 for '\u0038'...?


thanks in advance
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38456
    
  23
I trust you know that 38hex means 56dec?
So your compiler goes through the code, and converts all your Unicode escapes to displayed characters. Your \u0038 becomes 8 and your '\u0038' becomes '8'. That is done before you compile anything. I presume you can work out how 8f becomes 8.0 and how '8' becomes 56, now.
Ivan Jozsef Balazs
Rancher

Joined: May 22, 2012
Posts: 867
    
    5
(too slow - deleted)

Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2249
    
  47
The unicode character \u0038 is '8' so in the first case the value 8 is assigned to the variable. In the second case you are assigning the char with a value of \u0038. This is a Hex value which when converted to decimal is 56.

Edit: Even slower
sr shashidhar
Greenhorn

Joined: Jan 17, 2013
Posts: 27

Now i got.
Thanks Campbell Ritchie , Tony Docherty
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38456
    
  23
You’re welcome
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Unicode Representation