java.lang.Long toString()


The Long.toString() java method returns a String object representing this Long’s value. The value is converted to signed decimal representation and returned as a string, exactly as if the long value were given as an argument to the toString(long) method.

Method Syntax

public static int toString()

Method Argument

Data Type Parameter Description

Method Returns

The toString() method of Long class returns a string representation of the value of this object in base 10.


Requires Java 1.0 and up

Java Long toString() Example

Below is a simple java example on the usage of toString() method of Long class.


 * This example source code demonstrates the use of  
 * toString() method of Long class

public class LongToStringExample {

	public static void main(String[] args) {
		// declare a new long value
		Long val = 88L;
		// get the toString() method result
		String result = val.toString();
		// print the result
		 * This is a standard method
		 * inherited by all classes to
		 * class Object


Sample Output

Below is the sample output when you run the above example.

Java Long toString() example output