by @codeexamples

Convert a long to string in Java

Home » java » Convert a long to string in Java

To convert a long to string, we can use the Long.toString() method in Java.

Here is an example:

long number = 123345678911L;

String str = Long.toString(number);

System.out.println(str);

Output:

12345678911

You can also use the String.valueOf() method to convert a long to string.

long number = 123345678911L;

String str = String.tovalueOf(number);

System.out.println(str);  // 12345678911