Java中从Double到String的转换
Given a double value and we have to convert it into string.
给定⼀个双精度值,我们必须将其转换为字符串。
Java conversion from Double to String
Java从Double转换为String
convert a Double to String, we use toString() method of Double class
toString() method of Double class, it accepts a double value and returns the To convert a Double to String
string value.
将Double转换为String ,我们使⽤Double类的toString()⽅法
Double类的toString()⽅法 ,该⽅法接受⼀个double值并返回字符串值。
为了将Double转换为String
Syntax:
句法:
Java代码将Double转换为String (Java code to convert a Double to String)
//Java code to convert a double to String
public class Main {
public static void main(String args[]) {
double a = 10;
double b = 20;
//variable to store result
String result = null;
/
/converting double to string
result = String(a);
System.out.println("result (value of a as string) = " + result);
result = String(b);
System.out.println("result (value of b as string) = " + result);
}
java的tostring方法}
Output
输出量
result (value of a as string) = 10.0
result (value of b as string) = 20.0
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论