static class Food{ String id; String name; Food(String A,String B) { this.id=A; this.name=B; } public void setId(String id) {this.id=id;} } public static void main(String[] args) { Food a=new Food("a","b"); Food b=new Food(null,"b"); List<Food> list1=Lists.newArrayList(a,b); List<Food> list2=list1.stream().filter(i->i.id!=null).collect(Collectors.toList()); list2.forEach(i->i.setId("x")); }