I have a string of the form number, number, number, ... and I pass the string to int numbers and put them in a arraylist, but the loop iteration makes me less and do not know why
This is my code:
ArrayList<Integer> servs = new ArrayList<Integer>();
String[] aux = result.split(";");
servs.clear();
for (int i =0; i< aux.length; i++)
{
servs.add( Integer.parseInt(aux[i]) );
}
I explain better how @Luiggi Mendoza says:
for example, if result is the string: 3;4;7 and I check the size of aux I get 3 which is correct, but after I check the size for servs and tells me is 2 and the values 3 and 4
When I consult information arraylist always missing the last element Can anyone help me? thanks
Aucun commentaire:
Enregistrer un commentaire