Java.lang Package Classes

Java Byte - toString() Method



The java.lang.Byte.toString() method returns a String object representing this Byte's value. The value is converted to signed decimal representation and returned as a string, exactly as if the byte value were given as an argument to the toString(byte) 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.Byte.toString() method returns a String object representing the given Byte's value.

import java.lang.*;

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

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

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

The output of the above code will be:

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

❮ Java.lang - Byte