CodesJava

Easy learning with example program codes

Long to string in java


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

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

Please follow and like us:
Posted in Java   


Copyright © 2019 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki