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