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 is compiler and what its output.
What is rmi and steps involved in developing an rmi object?
Is it possible for yielded thread to get chance for its execution again ?
What is a conditional equation?
What is a vector in java?
How does singleton class work?
What are the new features in java 8?
What is the use of default method in interface in java? Explain
What is the intersection and union methods?
How do you add an element to a set in java?
Which container method is used to cause a container to be laid out and redisplayed in java programming?
Why java is secure? Explain.
What are design patterns and please explain?
Can we override private methods?
What is literal example?