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








Byte parseByte(String s, int radix) parses the string to byte in the radix.

Syntax

parseByte has the following syntax.

public static byte parseByte(String s, int radix) throws NumberFormatException

Parameters

parseByte has the following parameters.

s
the String containing the byte
radix
the radix

Return

parseByte returns the byte value from the string in the radix

Example

In the following code we convert string 10 based on radix 8.

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

    System.out.println("parse string to byte:"+Byte.parseByte("10", 8));
  }
}

The output: