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 use of functional interface in java 8?
What is boolean strategy?
What is the use of callablestatement?
What is the difference between class & object?
What is a map in java?
What is a bufferedreader?
What is the difference between ArrayList and Vector? which one is better in Java
How can we make a class singleton?
What does java se mean?
Is it possible to override private or static method in java?
How will you call an Applet using Java Script Function?
How do you declare a string variable?
Name few "optional" classes introduced with java 8 ?
What is Garbage Collection in Java
Does sprintf allocate memory?