I am trying to compare one arrayList object elements contains another arraylist with below code but this is not working as i expected can some one help me please
arrayList1=[{productSku:"123"},{productSku:"1234"}]
arrayList2=[{productSku:"123"},{productSku:"1000"}]
My scenario is if arraylist1 elements not matching with any of the element in arraylist2 then we should throw exception
arrayList2.stream().filter(type -> "EQUIPMENT".equals(type.getItemType()))
.forEach(action -> {
arrayList1.forEach(action1 -> {
if (!action1.getProductSku().equalsIgnoreCase(action.getProductSKU())) {
// Throw exception
}
});
});