The source code to convert the byte into the string is given below. The given program is compiled and executed successfully.
// Java program to convert byte
// into the string
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner X = new Scanner(System.in);
String str;
byte bytVal = 0;
System.out.print("Enter byte value: ");
bytVal = X.nextByte();
//Convert byte value into string.
str = Byte.toString(bytVal);
System.out.println("String value: " + str);
}
}
Output:
Enter byte value: 124
String value: 124
Explanation:
In the above program, we imported "java.util.Scanner" to read input from the user. And, created a Main class that contains a method main().
Program/Source Code:
The source code to convert the byte into the string is given below. The given program is compiled and executed successfully.
Output:
Explanation:
In the above program, we imported "java.util.Scanner" to read input from the user. And, created a Main class that contains a method main().