What happens when you assigned a 'double' value to
a 'String'?

Answer Posted / pankaj

hi,
toString() method will also not work here.

double d=10.5;
String str= d.toString();

E:\Programs>javac conversionTest.java
conversionTest.java:6: double cannot be dereferenced
String str= d.toString();
^
1 error


The only way I found is as below and is working fine.

double d=10.5;
String str= ""+d+"";
System.out.println(str);

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why do we need strings in java?

509


Can we overload the constructors?

547


What do you mean by hashing?

635


What is logical variable?

492


What are the two types of java?

504






how to deploy tomcatserver to weblogic server? write d following steps?

1432


What is the difference between exception and error in java?

482


What are the differences between throw and throws?

514


Can java cast null?

585


Explain where variables are created in memory?

569


Hi friends am new to java. I read jar file means collection of java files. For executing struts application what are the necessary jar files. " struts.jar " file contains what. can u explain

1417


Is there a case when finally will not execute?

549


Is integer a class?

556


Is a class an object?

565


Can you call a method on a null object?

550