I am trying to split a string as the code below
String []data = {"3.5,2.3,4.2,5.4,7.4,2.7"};
String s[] = data.split("\\,");
double point3[] = new Double [s.length];
double allPoint[] = new double [s.length];
for (int i = 0; i < s.length; i++){
point3[2] = Double.parseDouble(s[2]);
//lng[i] = Double.parseDouble(s[i]);
allPoint[i] = Double.parseDouble(s[i]);
}
I also tried with data.split(","); But the problem is not with backslashes, it gives error at split and hint shows that
cannot find symbol, symbol: method split(String)
I'm unable to import split
what can I do now.
The method split() belongs to String, not to Array. To make this work, you must define your data as String data = "3.5,2.3,4.2,5.4,7.4,2.7"; instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With