I try with a loop like that
// ArrayList tourists for (Tourist t : tourists) { if (t != null) { t.setId(idForm); } }
I used the stream interface together with the stream operation collect and a helper-method to generate an new list.
tourists.stream().filter(this::isNotNull).collect(Collectors.toList()); private boolean isNotNull(final T item) { return item != null; }