Convert a string to long in Java
To convert a string to long, we can use the Long.valueOf()
method in Java.
Here is an example:
String str = "1234854";
long number = Long.valueOf(str);
System.out.println(number);
Output:
1234854
Alternatively, you can also use new Long()
constructor to convert a string to long.
String str = "1234854";
long number = new Long(str);
System.out.println(number); // 1234854