Java tutorial
//package com.java2s; import java.util.Collection; public class Main { public static <T> void addIfNotNull(Collection<T> col, T val) { if (val != null) { col.add(val); } } }