Export (0) Print
Expand All

Byte.valueOf Method (String)

Visual Studio 2005

Returns the Byte object represented by a string parameter.

Package: java.lang

Assembly: vjslib (in vjslib.dll)


public static java.lang.Byte valueOf(
    java.lang.String str) throws java.lang.NumberFormatException;

Parameters

str

The string to be parsed.

The Byte object represented by str.

// bt-ValOf1.jsl
// Byte.valueOf example

public class MyClass
{
    public static void main(String[] args)
    {
        String s = new String("-128");
        Byte b = Byte.valueOf(s);
        System.out.print("The byte is: " + b);
    } 
}

/*
Output:
The byte is: -128
*/

The string characters must all be decimal digits except the first character, which can be a minus sign (-).

If the string could not be parsed to a signed decimal byte, the exception java.lang.NumberFormatException is thrown.

Community Additions

ADD
Show:
© 2015 Microsoft