Byte.valueOf() byte in Java

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

Syntax:

Byte java.lang.Byte.valueOf(byte b)

This method takes one argument of type byte as its parameter. This method returns a Byte instance representing the specified byte value.

Parameters: One parameter is required for this method.

b: a byte value.

Returns: a Byte instance representing b.

For Example:

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

Approach

Java

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

        byte b = (byte123;
        System.out.println(Byte.valueOf(b));

    }
}

Output:

123

No comments:

Post a Comment