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 advantage do java's layout managers provide over traditional windowing systems?
Is sizeof a preprocessor?
What is unicode with example?
Explain different types of wrapper classes in java?
Explain enumeration in java?
Can you use this() and super() both in a constructor?
What is java Applet?
What is method overriding in java ?
What is meant by interface?
How variables are declared?
What do you mean by hashing?
What are the 4 versions of java?
Explain the scope of a variable.
What is the difference between state-based unit testing and interaction-based unit testing?
how are methods defined?