Android examples for java.util:Collection and Null
add Not Null Element to Collection
//package com.book2s; import java.util.Collection; public class Main { public static <E> boolean addNotNullElement(Collection<E> c, E e) { if (!isNotNull(c)) { return false; }//from w w w .j a v a 2 s. com if (e == null) { return false; } c.add(e); return true; } public static boolean isNotNull(Collection<?> c) { if (c == null || c.isEmpty()) { return false; } else { return true; } } }