Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

not getting converted to string

 
Karthikeyan Pandian
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



In 18 th line the double is not getting converted to string, its givng the same value with quotations. please tell the misake there. Thank you
 
James X Peterson
Whizlabs Java Support
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Karthikeyan Pandian wrote:


In 18 th line the double is not getting converted to string, its givng the same value with quotations. please tell the misake there. Thank you



The output will not be in double quotes. The output will be 3.14 .
 
fred rosenberger
lowercase baba
Bartender
Posts: 12185
34
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is hte output:

C:\>java Iron
c
9
48
90
3.14
3.14
3.14
fe
 
Karthikeyan Pandian
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But in K & B book , the output is enclosed within the quotes.. In page no 242 (Chapter Assignments).. Please sort me out the query..
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that's just a convention to indicate it's printing a String value rather than a numeric value. The output is as you see.
 
Thakur Sachin Singh
Ranch Hand
Posts: 248
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Matthew Brown, you are right. It is convention because result coming same so writer of the book differentiate the result mentioning there quotes("").
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic