In this example we will show how to convert a String object into long primitive type with parseLong method of Long class.
Source Code
package com.beginner.examples;
public class String2LongExample {
public static void main(String[] args){
String str = new String("14");
//String converted to long
long lp = Long.parseLong(str);
System.out.println(lp);
}
}
Output:
14