Java convert string to long using Long.parseLong() method
package com.w3schools;
public class StringToLong {
public static void main(String args[]){
String str = "578115";
//convert string to long
long num = Long.parseLong(str);
System.out.println(num);
}
}
Output:
578115
Download this example.
Java convert string to long using Long.valueOf() method
package com.w3schools;
public class StringToLong {
public static void main(String args[]){
String str = "578115";
//convert string to long
long num = Long.valueOf(str);
System.out.println(num);
}
}
Output:
578115
Download this example.