I try with a loop like that
// ArrayList tourists for (Tourist t : tourists) { if (t != null) { t.setId(idForm); } }
There is an easy way of removing all the null values from collection.You have to pass a collection containing null as a parameter to removeAll() method
null
collection
removeAll()
List s1=new ArrayList(); s1.add(null); yourCollection.removeAll(s1);