I have a string which has numbers. I have to parse this string and store these numbers in int, float, etc. Accordingly
String str = "100,2.0,-100,19.99,0";
I can do it by Integer.parseInt()
and Float.parseFloat()
after splitting. But I can't do it for negative number. It throws exception java.lang.NumberFormatException
. After searching web I couldn't find any solution for this problem.
So how can I parse a negative integer from string and store into int using j2me api set?