Java tutorial
//package com.java2s; //License from project: Apache License import java.util.Collection; public class Main { static <V> void addAllIfNotNull(final Collection<V> collection, final Collection<V> values) { if (collection != null && values != null) { collection.addAll(values); } } static <V> void addAll(final Collection<V> collection, final Iterable<V> values) { if (values != null) { for (final V value : values) { collection.add(value); } } } }