Convert byte to String in Java


The valueOf() method is used in Java to convert byte to string.

Let’s say we have the following byte value.

byte val = 40;

Converting the above byte to string.

String.valueOf(val);

Example

 Live Demo

public class Demo {
   public static void main(String[] args) {
      byte val = 40;
      // converting
      String str = String.valueOf(val);
      System.out.println("String: "+str);
   }
}

Output

String: 40

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 26-Jun-2020

615 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements