Convert from String to long in Java
Description
The following code shows how to convert from String to long.
Example
// ww w . ja v a 2 s. c om
public class Main {
public static void main(String[] args) throws Exception {
String str = "0.5";
long l = Long.valueOf(str).longValue();
// or
Long L = Long.parseLong(str);
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »