Java Data Type Tutorial - Byte valueOf(String s, int radix) throws NumberFormatException example








Byte valueOf(String s, int radix) converts string to a Byte with the radix.

Syntax

valueOf has the following syntax.

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

Parameters

valueOf has the following parameters.

s
the string to be parsed
radix
the radix to be used in interpreting s

Return

valueOf returns a Byte object from the string argument.

Example

In the following code shows how to use Byte.valueOf(String s, int radix) method.

public class Main {
  public static void main(String[] args) {
    
    System.out.println("parse string to byte:"+Byte.valueOf("10", 8));
  }
}

The output: