Convert long value to String in Java
static String valueOf(long b) method of String class can be used to convert a long value to String in Java.
For eg. when we pass a long value '55555555' to valueOf method, it returns a string value '55555555'.
Example 1
class LtoSTest{
public static void main(String args[]){
long l=99999999;
String ltoSt=String.valueOf(l);
System.out.println(ltoSt);
}
}
Output 1
99999999
Example 2
class LtoSTest{
public static void main(String args[]){
long lo=12345678;
String ltoSt=String.valueOf(lo);
System.out.println(ltoSt);
}
}
Output 2
12345678