Hackerss.com

hackerss
hackerss

Posted on

Convert long to string in Java

Convert long to string - Java:


import java.io.*;

public class LongToString {
   /**
   * This method convert long to string.
   * @param numberOne first param to convert.
   * @return String Obtains the string of numberOne.
   */   
   public String longToString(long numberOne) {
       //Variable to store the string
       String str = "";
       //Convert the long to string
       str = String.valueOf(numberOne);
       //Return the string
       return str;
   }

   /**
   * One Example
   */
   public static void main(String args[]) throws IOException {

      LongToString  longToString= new LongToString ();
      //Example
      String str = longToString.longToString(10);
      //Output
      System.out.println("10 is :" + str); //10
   }
}

Enter fullscreen mode Exit fullscreen mode

Top comments (0)