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








Byte parseByte(String s) parses the string argument as a byte.

Syntax

parseByte has the following syntax.

public static byte parseByte(String s) throws NumberFormatException

Parameters

parseByte has the following parameters.

s
a String containing the byte

Return

parseByte returns the byte value represented by the string

Example

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

The following code uses Byte.parseByte to convert string value to byte value.

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

The output: