Thursday, November 20, 2025
HomeLanguagesJavaByte toString() method in Java with examples

Byte toString() method in Java with examples

The toString() method of Byte class is a built in method in Java which is used to return a String value.

public String toString()

Syntax:

ByteObject.toString()

Return Value: It returns a String object, the value of which is equal to the value of the ByteObject.

Below is the implementation of toString() method:

Java




// Java code to implement
// toString() method of Byte class
  
class GFG {
    public static void main(String[] args)
    {
  
        // byte value
        byte value = 19;
  
        // creating a byte Object
        Byte b = new Byte(value);
  
        // toString() method in Byte class
        String output = b.toString();
  
        // printing the output
        System.out.println(output);
    }
}


Output:

19

public static String toString()

Syntax:

Byte.toString(byte b)

Parameters: It takes a byte value b as the parameter which is to be converted to String.

Return Type: It returns a String object, the value of which is equal to the value of the byte ‘b’.

Below is the implementation of toString() method:

Java




// Java code to implement
// toString() method of Byte class
  
class GFG {
    public static void main(String[] args)
    {
  
        // byte value
        byte value = 19;
  
        // toString() method og Byte class
        String output = Byte.toString(value);
  
        // printing the output
        System.out.println(output);
    }
}


Output:

19
RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32404 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6777 POSTS0 COMMENTS
Nicole Veronica
11925 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11994 POSTS0 COMMENTS
Shaida Kate Naidoo
6905 POSTS0 COMMENTS
Ted Musemwa
7160 POSTS0 COMMENTS
Thapelo Manthata
6861 POSTS0 COMMENTS
Umr Jansen
6846 POSTS0 COMMENTS