I have static ArrayList<Batch>. i want to remove which object contain productcode
This is my Batch Entity
public class BatchControl implements Parcelable{
private String productCode;
private String lotNumber;
private String batchSerialNumber;
private double quantity ;
private int sequence;
private String productName;
private String type;
//Setter & getter
}
This is my removing object
static ArrayList<String> lstString = new ArrayList<String>();
for (Iterator<Batch> i = lstString.iterator(); i.hasNext(); ) {
Batch value=(Batch )i.next();
if(value.getSequence() == iVal) {
lstString.remove(value);
}
}
iVal is Android TableLayout contain the row number.
String number = txtNumber.getText().toString();
iVal = Integer.parseInt(number);
But it didn’t remove which object have iValue. Because of the resoan static arraylist so, each & every time when i remove size going to change.
Please help me out.
Thanks in advance.
When using an
Iteratoron a list, you can safely remove the current element (regarding position or index in the list) withIterator.remove().Take into account that using
remove()on astatic Listcan yield to problems if there are concurrent modifications on theList. CitingIterator.remove()‘s javadoc: