Convert String to long in Java

With the help of Long.parseLong() method, you can convert String to long in Java.

Example of Java String to long conversion

Following is the example that will show conversion from String to long-

public class Example
{
	public static void main(String args[])
	{
		String s = "123456789";
		long l = Long.parseLong(s);
		System.out.println(l);
	}
}

Output

123456789