Byte.valueOf(): This method is available in the java.lang.Byte class of Java.
Syntax:
Byte java.lang.Byte.valueOf(String s) throws NumberFormatException.
This method takes one argument of type String as its parameter. This method returns a Byte object holding the value given by the specified String. The argument is interpreted as representing a signed decimal byte.
Parameters: One parameter is required for this method.
s: the string to be parsed.
Returns: a Byte object holding the value represented by the string argument.
Throws: NumberFormatException - If the String does not contain a parsable byte.
For Example:
Byte.valueOf("124") = > It returns 124.
Approach
Java
public class BytevalueOfString {public static void main(String[] args) {String s = "124";System.out.println(Byte.valueOf(s));}}
Output:
124
No comments:
Post a Comment