Convert byte value to string value

Two methods we can use to convert a byte value to a string value. First method is the toString method from Byte class

String toString()
Returns a String object representing this Byte's value.

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


  }
}

The outputs:


str:10

Another way is to use the static method toString(byte b).

static String toString(byte b)
Returns a new String object representing the specified byte.

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

  }
}

The output:


str:10
Home 
  Java Book 
    Essential Classes  

Byte:
  1. Byte
  2. Find out byte's max value, min value and size
  3. Create Byte object with its constructor
  4. Convert Byte to byte, double, float, int, long and short
  5. Decode a string to a byte
  6. Byte class defines static methods to convert string value to byte value
  7. Convert byte value to string value
  8. Compare two byte values