You may use the String.split()
method:
String[] tokens = str.split(",");
After that, use Double.parseDouble()
method to parse the string value to a double.
double latitude = Double.parseDouble(tokens[0]);
double longitude = Double.parseDouble(tokens[1]);
Similar parse methods exist in the other wrapper classes as well – Integer
, Boolean
, etc.