Java Byte parseByte() methodThe 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. ThrowsThe parseByte() method throws: NumberFormatException- if the string does not contain a parsable byte. Return ValueThis method returns the byte value represented by the argument in decimal. Example 1Test it NowOutput: -8 Example 2Test it NowOutput: 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 3Test it NowOutput: 113 Example 4Test it NowOutput: 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 |
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