In this tutorial we will learn how to convert a string type data to long type data.
This program will take a String value from mystring variable. The line long mylong = Long.parseLong(mystring); converts the mystring string type value to mylong long type value. The parseLong() method coverts the any type data to long type data.
class Stringtolong {
public static void main(String[] args) {
try {
String mystring = "123456789";
long mylong = Long.parseLong(mystring);
System.out.println("Converted value from String to long is: "
+ mylong);
} catch (Exception e) {
System.out.println(" Error " + e);
}
}
};

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.