I have to remove the Object if the value is 0. By using this code, only several were removed, but some were not.
public static List<DataEntityInteger> removeZeroValue(List<DataEntityInteger> list) {
for (int a=0; a<list.size(); a++) {
DataEntityInteger entityInteger = list.get(a);
if (entityInteger.getValue() == 0) {
list.remove(a);
}
}
return list;
}
DataEntityInteger
class:
public class DataEntityInteger {
@SerializedName("keyname")
@Expose
private String keyname;
@SerializedName("value")
@Expose
private Integer value;
public String getKeyname() {
return keyname;
}
public void setKeyname(String keyname) {
this.keyname = keyname;
}
public Integer getValue() {
return value;
}
public void setValue(Integer value) {
this.value = value;
}
}
So my question is, how can I remove all the zero-valued object in the ArrayList
?