I read a CSV file,which looks as shown below.
,Tmt 1,Tmt 2,Tmt 3
delta 1,-104,-100,-103
delta 2,-125,-103,-103
delta 3,-104,-100,failed
Later, I parsed the csv file and took in all of its elements to an ArrayList of Strings. Now the ArrayList looks like
[Tmt 1, Tmt 2, Tmt 3, delta 1, -104, -100, -103, delta 2, -125, -103, -103, delta 3, -104, -100, failed]
Now, I want to remove all the elements of the String ArrayList (shown above) which starts with an alphabet. I used the following code to do that. (al1 is the ArrayList I mentioned above and temp is the String I'm using to check the elements of al1)
for(int i=0;i<al1.size();i++)
{
temp = al1.get(i);
if (temp.charAt(0)=='-'|| (Character.isDigit(temp.charAt(0))==false))
{
al1.remove(i);
}
}
System.out.print(al1);
Now after the code runs and hoping to remove elements of al1 starting with an alphabet , I printed the ArrayList al1, and the result was as follows:
[Tmt 2, delts 1, -100, delta 2, -103, delta 3, -100]
(and this was not what I expected)
Please Help.. thanks in advance
i--after theremovecall. Or you could work your way from the end of the list towards the start.