I am trying to convert a string to a double but get a NumberFormatException.
Here is my code:
String x = "";
// String ary[]=new String[10];
while (finalstr.charAt(stpr) != ' ') {
// System.out.print(finalstr.charAt(stpr));
Character c = new Character(finalstr.charAt(stpr));
String s = c.toString(c);
ary[i] = s;
x = x + ary[i];
i++;
stpr++;
// first++;
}
// System.out.print(x);
String yo = x;
// System.out.print(yo); //it prints well
// double d = Double.valueOf(yo.trim()).doubleValue();
double doubleprim = Double.parseDouble(yo);
System.out.print(doubleprim);
All help appreciated.