I try with a loop like that
// ArrayList tourists for (Tourist t : tourists) { if (t != null) { t.setId(idForm); } }
We can use iterator for the same to remove all the null values.
Iterator itr= tourists.iterator(); while(itr.hasNext()){ if(itr.next() == null){ itr.remove(); } }