Long to string in java

Java convert long to string using Long.toString() method

package com.w3schools;

public class LongToString {
  public static void main(String args[]){
      long var = 765123;
      //convert long to string
      String str = Long.toString(var);
      System.out.println("String is: "+str);
  }
}

Output:

String is: 765123

Download this example.

Java convert long to string using String.valueOf() method

package com.w3schools;

public class LongToString {
  public static void main(String args[]){
       long var = 765123;
      //convert long to string
      String str = String.valueOf(var);
      System.out.println("String is: "+str);
  }
}

Output:

String is: 765123

Download this example.