在Java中从Float转换为String
Given a float value and we have convert it into string.
给定⼀个float值,我们已经将其转换为字符串。
Java conversion from Float to String
Java从Float转换为String
convert a Float to String, we use toString() method of Float class
toString() method of Float class, it accepts a float value and returns the string To convert a Float to String
value.
将Float转换为String ,我们使⽤Float类的toString()⽅法
Float类的toString()⽅法 ,该⽅法接受⼀个float值并返回字符串值。
为了将Float转换为String
Syntax:
句法:
Java代码将Float转换为String (Java code to convert a Float to String)
//Java code to convert afloat to String
public class Main {
public static void main(String args[]) {
float a = 10.23f;
float b = 23.456f;
//variable to store result
String result = null;
/
/converting float 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);
}
}
Outputjava的tostring方法
输出量
result (value of a as string) = 10.23
result (value of b as string) = 23.456
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论