Tutorialspoint examples

Learn java tutorial with examples for beginners online

Convert long to string java program


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

package com.tutorialspointexamples;
 
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.tutorialspointexamples;
 
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.

Download tutorialspointexamples Android App
Copyright © 2018 Tutorialspoint examples DMCA.com Protection Status