add object to Collection, null safe - Android java.util

Android examples for java.util:Collection and Null

Description

add object to Collection, null safe

Demo Code


//package com.java2s;
import java.util.Collection;

public class Main {

    public static boolean add(Collection collection, Object object) {
        if (collection == null || object == null)
            return false;
        collection.add(object);//from   w w  w  . j  a v a 2s. c  o  m
        return true;
    }
}

Related Tutorials