Java program to convert byte into the string

Given/input a byte, we have to convert it into the string.
Submitted by Nidhi, on March 15, 2022

Problem Solution:

In this program, we will read a byte value from the user and convert the input byte value into the string Byte.toString() method.

Program/Source Code:

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(;
    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);


Enter byte value: 124
String value: 124


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().

The main() method is the entry point for the program, here we read a byte value from the user using the Scanner class. Then we converted the input byte value into a string using the Byte.toString() method and printed the result.

Java Conversion Programs »


Comments and Discussions!


Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.