Byte.toString() in Java

Byte.toString(): This method is available in the java.lang.Byte class of Java.

Syntax:

String java.lang.Byte.toString(byte b)

This method takes one argument of type byte as its parameter. This method returns a new String object representing the specified byte. The radix is assumed to be 10.

Parameters: One parameter is required for this method.

b: The byte to be converted.

Returns: the string representation of the specified byte.

For Example:

Byte.toString(123) = > It returns 123.

Approach

Java

public class BytetoString {
    public static void main(String[] args) {

        byte b = 123;
        System.out.println(Byte.toString(b));

    }
}

Output:

123

No comments:

Post a Comment