Java中从Long到String的转换
Given a long value and we have to convert it into string.
给定⼀个长值,我们必须将其转换为字符串。
Java conversion from Long to String
Java从Long转换为String
convert a Long to String, we use toString() method of Long class
toString() method of Long class, it accepts a long value and returns the string To convert a Long to String
value.
Long转换为String ,我们使⽤Long类的toString()⽅法
Long类的toString()⽅法 ,该⽅法接受long值并返回字符串值。
要将Long转换为String
Syntax:
句法:
Java代码将Long转换为String (Java code to convert a Long to String)
//Java code to convert along to String
public class Main {
public static void main(String args[]) {
long a = 112120;
long b = 2121210;
//variable to store result
String result = null;
/
/converting long 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);
}
}
Output
输出量java的tostring方法
result (value of a as string) = 112120
result (value of b as string) = 2121210

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。