In this article, we will show you how to convert Java wrapper class Byte or primitive type byte to String code examples. There are different ways we can convert Java Byte to String.
/**
* Class to Convert Byte To String Example
* @author javaguides.net
*
*/
public class ConvertByteToStringExamples {
public static void main(String[] args) {
/*
* Method 1: using valueOf() method of String class.
*/
byte b = 10;
String strByte = String.valueOf(b);
System.out.println("Convert byte to string using valueOf method ::" + strByte);
/*
* Method 2: using toString() method of Byte class
*/
String strByte1 = Byte.toString(b);
System.out.println("Convert Byte to String using Byte.toString method ::" + strByte1);
}
}
Output:
Convert byte to string using valueOf method ::10
Convert Byte to String using Byte.toString method ::10
Related Java String Conversion Examples
- Java Convert Integer to String Example
- Java Convert Float to String Example
- Java Convert Double to String Example
- Java Convert Short to String Example
- Java Convert Long to String Example
- Java Convert Character to String Example
- Java Convert Byte to String Example
- Java Convert Boolean to String Example
Free Spring Boot Tutorial | Full In-depth Course | Learn Spring Boot in 10 Hours
Watch this course on YouTube at Spring Boot Tutorial | Fee 10 Hours Full Course