This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

char declaration problem

 
Jayant Raj
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Please explain the output to me..

=====================================
char c ='\71';
System.out.println("c is :: " + c);

ANSWER : 9
=====================================

How is this char declaration evaluated?
 
Arvind Giri
Ranch Hand
Posts: 91
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
its \uuu where u is an octal value.
hence \71 = 57 = '9'
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
'\71' is a bad way to write it. It would be better written as '\071', then it is clearly octal because of the leading zero. On the other hand '\111' is also using octal digits and is legal.
[ August 19, 2005: Message edited by: Barry Gaunt ]
 
nagaraj raja
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai ArvindGiri,

 
nagaraj raja
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai ArvindGiri,

Here i didn't understand how 57 will convert into '9' plz explain
 
Jay Pawar
Ranch Hand
Posts: 411
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello nagaraj raja
ASCII value 57 corresponds to character 9. For more details check the decimal value 57 in this ASCII chart here
Hope that helps
 
Jayant Raj
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it required for us to remember all these ASCII values, for SCJP?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic