what is the correct way to iterate through an array list without getting an exception thrown? I tried this:
while(packages.get(i)!=null)
{
if(packages.get(i).equals(z))
{
packages.remove(i);
this.setNumPack(this.getNumPack()-1);
}
i++;
}
It throws exception when the index is bigger than the size of the array list.I also tried to iterate as long as the iterator was smaller than the size of the array but it didnt help. Thanks