This documentation is archived and is not being maintained.

Long.parseLong Method (String)

Visual Studio 2005

Returns the long value represented by a string parameter.

Package: java.lang

Assembly: vjslib (in vjslib.dll)

public static long parseLong(
    java.lang.String str) throws java.lang.NumberFormatException;



The string to be parsed.

The long value represented by the string parameter.

// l-parseLong1.jsl
// Long.parseLong example

public class MyClass
    public static void main(String[] args)
        String s = new String("123");
        long l = Long.parseLong(s);
        System.out.print("The long value is: " + l);

The long value is: 123

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

The returned value is a signed long in the decimal radix.

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