Hi I have two custom array lists, I want to remove the similar items from one array list that are matched with the second array lists.
Here is my logic that I'm using.
List<Daily_Stock_Pojo> dailyStockArrayListOne = new ArrayList<Daily_Stock_Pojo>();
List<Daily_Stock_Pojo> dailyStockArrayListTwo = new ArrayList<Daily_Stock_Pojo>();
List<Daily_Stock_Pojo> added = new ArrayList<Daily_Stock_Pojo>(dailyStockArrayListOne);
added.removeAll(dailyStockArrayListTwo);
Also below one is my custom class used as an Object for the array lists.
public class Daily_Stock_Pojo {
private Date Calendar_Date;
private int Store_Id;
private int Item_Id;
private int Stock_Volume;
private String MRP;
private String objectId;
public Daily_Stock_Pojo(Date calendar_Date, int store_Id, int item_Id, int stock_Volume, String MRP, String objectId) {
Calendar_Date = calendar_Date;
Store_Id = store_Id;
Item_Id = item_Id;
Stock_Volume = stock_Volume;
this.MRP = MRP;
this.objectId = objectId;
}
public Date getCalendar_Date() {
return Calendar_Date;
}
public void setCalendar_Date(Date calendar_Date) {
Calendar_Date = calendar_Date;
}
public int getStore_Id() {
return Store_Id;
}
public void setStore_Id(int store_Id) {
Store_Id = store_Id;
}
public int getItem_Id() {
return Item_Id;
}
public void setItem_Id(int item_Id) {
Item_Id = item_Id;
}
public int getStock_Volume() {
return Stock_Volume;
}
public void setStock_Volume(int stock_Volume) {
Stock_Volume = stock_Volume;
}
public String getMRP() {
return MRP;
}
public void setMRP(String MRP) {
this.MRP = MRP;
}
public String getObjectId() {
return objectId;
}
public void setObjectId(String objectId) {
this.objectId = objectId;
}
}
Give me a solution on how to compare two custom array lists and remove all the items from the first array list that are matched with the second array list.