Java Byte decode() methodThe 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 1Test it NowOutput: 12 Example 2Test it NowOutput: 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 3Test it NowOutput: 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 |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India