I have a string with this content 12345.
What's the best way to read these individual numbers into an ArrayList of integers? like this:
{1, 2, 3, 4, 5}
Here is what I have so far:
String data = getData();
this.points=new ArrayList<Integer>();
for (int i=0; i<data.length(); i++) {
int pt = Integer.parseInt(data.valueOf(i));
this.points.add(new Integer(pt));
}
The problem is that I get [(0),(1),(2),...] instead of the numbers required.
String.valueOfdoes - it does not do what you think it does.