Javatpoint Logo
Javatpoint Logo

Java Byte decode() method

The decode() method of Java Byte class decodes a String into a Byte. It can accept decimal, hexadecimal and octal numbers.

Syntax:

Parameters:

The parameter 'nm' represents the String to decode.

Throws:

The decode() method throws :

NumberFormatException- if the String does not contains a parsable byte.

Return Value

This method returns a Byte object holding the byte value of string 'nm'.

Example 1

Test it Now

Output:

12

Example 2

Test it Now

Output:

Exception in thread "main" java.lang.NumberFormatException: For input string: "null"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.lang.Integer.parseInt(Integer.java:580)
	at java.lang.Integer.valueOf(Integer.java:740)
	at java.lang.Integer.decode(Integer.java:1197)
	at java.lang.Byte.decode(Byte.java:277)
	at com.JavaTpoint.JavaByteDecodeExample2.main(JavaByteDecodeExample2.java:6)

Example 3

Test it Now

Output:

Exception in thread "main" java.lang.NumberFormatException: For input string: "Byte.MIN_VALUE"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.lang.Integer.parseInt(Integer.java:580)
	at java.lang.Integer.valueOf(Integer.java:740)
	at java.lang.Integer.decode(Integer.java:1197)
	at java.lang.Byte.decode(Byte.java:277)
	at com.JavaTpoint.JavaByteDecodeExample3.main(JavaByteDecodeExample3.java:7)

Next TopicJava Byte





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback

  • Send your Feedback to feedback@javatpoint.com

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA