Java Byte decode() methodLast Updated : 17 Mar 2025 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 ValueThis method returns a Byte object holding the byte value of string 'nm'. Example 1ExampleCompile and RunOutput: 12 Example 2ExampleCompile and RunOutput: 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.TpointTech.JavaByteDecodeExample2.main(JavaByteDecodeExample2.java:6) Example 3ExampleCompile and RunOutput: 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.TpointTech.JavaByteDecodeExample3.main(JavaByteDecodeExample3.java:7) Next TopicJava Byte |
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India