Java.lang.Long.parseLong() Method
Advertisements
Description
The java.lang.Long.parseLong(String s) method parses the string argument s as a signed decimal long.
Declaration
Following is the declaration for java.lang.Long.parseLong() method
public static long parseLong(String s) throws NumberFormatException
Parameters
s -- This is a String containing the long representation to be parsed.
Return Value
This method returns the long represented by the argument in decimal.
Exception
NumberFormatException -- if the string does not contain a parsable long.
Example
The following example shows the usage of java.lang.Long.parseLong() method.
package com.tutorialspoint;
import java.lang.*;
public class LongDemo {
public static void main(String[] args) {
// parses the string argument
long a = Long.parseLong("1452");
long b = Long.parseLong("26");
long c = Long.parseLong("54");
long m = a * b * c;
System.out.print("Value after multiplying = " + m);
}
}
Let us compile and run the above program, this will produce the following result:
Value after multiplying = 2038608