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 regex in java?
What is merge sort in java?
Can a top level class be private or protected?
What is rule of accessibility in java?
What is the use of 'super' keyword inside a constructor?
How to find the largest value from the given array.
How do you sort objects in java?
Why super is first line in java?
What is oop in java?
What are the difference between string, string builder, and string buffer in java?
What do you mean by ordered and sorted in collections in java?
Define an applet in java?
Why volatile is used in java?
What is the default access specifier for variables and methods of a class?
Can we execute a program without main() method?