Java convert string to long using Long.parseLong() method
package com.w3spoint;
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);
}
} |
package com.w3spoint; 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:
Download this example.
Java convert string to long using Long.valueOf() method
package com.w3spoint;
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);
}
} |
package com.w3spoint; 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:
Download this example.