Java Data Type Tutorial - Byte toString(byte b) example








Byte toString(byte b) converts byte to Byte.

Syntax

toString has the following syntax.

public static String toString(byte b)

Parameters

toString has the following parameters.

b
the byte to be converted

Return

toString returns the string representation of the specified byte

Example

In the following code shows how to use Byte.toString(byte b) method.

The code below calls the static method to do the conversion.

public class Main {
  public static void main(String[] args) {
    
    byte b = 10;
    System.out.println("str:"+Byte.toString(b));

  }
}

The output: