java.lang.Byte valueOf(String s, int radix)

Description

The valueOf(String s, int radix) method of Byte class returns a Byte object holding the value extracted from the specified String when parsed with the radix given by the second argument. The first argument is interpreted as representing a signed byte in the radix specified by the second argument, exactly as if the argument were given to the parseByte(java.lang.String, int) method. The result is a Byte object that represents the byte value specified by the string.

In other words, this method returns a Byte object equal to the value of:

new Byte(Byte.parseByte(s, radix))

Important Notes:

  • The method  valueOf(String s, int radix) throws  NumberFormatException, if the String does not contain a parsable byte.

Method Syntax

public static Byte valueOf(String s, int radix)
throws NumberFormatException

Method Argument

Data Type Parameter Description
String s the string to be parsed
int radix the radix to be used in interpreting s

Method Returns

The valueOf(String s, int radix) method of Byte class returns a Byte object holding the value represented by the string argument in the specified radix.

Compatibility

Requires Java 1.1 and up

Java Byte valueOf(String s, int radix) Example

Below is a simple java example on the usage of valueOf(String s, int radix) method of Byte class.

Sample Output

Below is the sample output when you run the above example.

java Byte valueOf(String s, int radix) example output