Java.lang Package Classes

Java Short - toString() Method



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

Syntax

public String toString()

Parameters

No parameter is required.

Return Value

Returns a string representation of the value of this object in base 10.

Exception

NA.

Example:

In the example below, the java.lang.Short.toString() method returns a String object representing the given Short's value.

import java.lang.*;

public class MyClass {
  public static void main(String[] args) {
    
    //creating Short object
    Short x = 25;

    //printing the Short object 
    System.out.println("The Short object is: " + x); 

    //creating and printing the string representation
    //of the Short object's value
    String x_tostring = x.toString();
    System.out.println("The string value of Short is: " + x_tostring);   
  }
}

The output of the above code will be:

The Short object is: 25
The string value of Short is: 25

❮ Java.lang - Short