Java Collection Clear clear(Collection collection)

Here you can find the source of clear(Collection collection)

Description

A null-safe way to clear a collection that might not be initialized

License

Open Source License

Parameter

Parameter Description
collection The collection to clear

Declaration

public static void clear(Collection<?> collection) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.Collection;

public class Main {
    /**//from   w w w  . j av a2 s. co  m
     * A null-safe way to clear a collection that might not be initialized
     * @param collection The collection to clear
     */
    public static void clear(Collection<?> collection) {
        if (collection != null)
            collection.clear();
    }
}

Related

  1. cleanup(AnyCollection collection)
  2. clear(Collection collection)
  3. clear(Collection collection)
  4. clear(final Collection collection)
  5. clearAndAddAll(final Collection where, final Collection fromWhere)