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
What does a void function return?
Why does java not support operator overloading?
When throws keyword is used?
What is array initialization in java?
Explain about main thread in java?
What is a wrapper method?
What is the history of java?
What are triggers in DB? Explain their types. How do they work?
Explain the difference between jdk, jre, and jvm?
How do you test a method for an exception using junit?
What does flag mean in java?
Differentiate between class and structure.
Why is java multithreaded?
what is the purpose of using rmisecuritymanager in rmi?
Can we have a method name same as class name in java?