Java tutorial
//package com.java2s; import java.util.Collection; public class Main { public static void addIfNotNull(Collection c, Object element) { if (element != null) { c.add(element); } } }