Javatpoint Logo
Javatpoint Logo

Java Byte parseByte() method

The parseByte() method of Java Byte class parses the string argument as a signed decimal. All the characters in the String should be decimal digits, except the first character which can be an ASCII minus or plus sign.

The second parameter parses the specified string argument as a signed byte in the specified radix.

Syntax:

Parameters:

The parameters 's' and 'radix' represent the string to be parsed and the radix to be used while parsing s.

Throws

The parseByte() method throws:

NumberFormatException- if the string does not contain a parsable byte.

Return Value

This method returns the byte value represented by the argument in decimal.

Example 1

Test it Now

Output:

-8

Example 2

Test it Now

Output:

Exception in thread "main" java.lang.NumberFormatException: radix 0 less than Character.MIN_RADIX
	at java.lang.Integer.parseInt(Integer.java:546)
	at java.lang.Byte.parseByte(Byte.java:149)
	at com.JavaTpoint.JavaByteParseByteExample2.main(JavaByteParseByteExample2.java:8)

Example 3

Test it Now

Output:

113

Example 4

Test it Now

Output:

36
Exception in thread "main" java.lang.NumberFormatException: Value out of range. Value:"null" Radix:36
	at java.lang.Byte.parseByte(Byte.java:151)
	at com.JavaTpoint.JavaByteParseByteExample4.main(JavaByteParseByteExample4.java:8)

Next TopicJava Byte





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA