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








Byte valueOf(String s) converts String to a Byte.

Syntax

valueOf has the following syntax.

public static Byte valueOf(String s) throws NumberFormatException

Parameters

valueOf has the following parameters.

s
the string to be parsed

Return

valueOf returns a Byte object from the string argument

Example

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

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

The output: