I am attempting to turn an array list of strings into an arraylist of floats. I have declared the two as such:
ArrayList<Float> AFFloat = new ArrayList<Float>();
ArrayList<String> AFUni0 = new ArrayList<String>();
AFUni is an array list that was parsed from a file. It holds values such as:
[0.059, 0.059, 0.029, 0.412, 0.029, 0.452, 0.386, 0.432, 0.114,0.318, 0.159,0.045, 0.432, 0.477, 0.045...]
I am trying to make those string values into actual numeric values with this set of code:
for (String wntFl:AFUni0){
AFFloat.add(Float.valueOf(wntFl));
}
But for some reason it isn't working. It is coming back with this error:
java.lang.NumberFormatException: For input string: "0.114,0.318"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1222)
at java.lang.Float.valueOf(Float.java:388)
at allelefreq.AlleleFreq.main(AlleleFreq.java:122)
Does anyone know why this is happening? Thanks
Stringvalue contains two float values, you didn't do the splitting correctly, it seems.