Convert byte to String in Java

Convert byte to String in Java Example describes about Convert byte to String in Java.

Byte class helps to wrap the primitive type value of byte in an object

In addition, Byte class provides several useful methods for dealing with a byte primitives.

When you need to Convert byte to String in Java, we can use Byte.toString(byte b) method of Byte class, This will convert the byte to String.

If you need a Byte object in lieu of primitive byte, you can use method Byte.valueOf(byte b). This method will convert the byte primitive to Byte Object

Convert byte To String In Java

public class ConvertByteToString {

 
public static void main(String[] args) {
  
   
byte b = 10;
  
   
// convert byte to String type
   
System.out.println(Byte.toString(b));
  
   
// converting byte primitive to Byte Object
   
System.out.println(Byte.valueOf(b));
  
 
}
}
Output
10

10








Your email address will not be published. Required fields are marked *