Convert byte to String in Java

Java 8Object Oriented ProgrammingProgramming

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
raja
Published on 13-Dec-2018 09:43:20
Advertisements