Java Utililty Methods Collection Clear

List of utility methods to do Collection Clear

Description

The list of methods to do Collection Clear are organized into topic(s).

Method

AnyCollectioncleanup(AnyCollection collection)
Cleanups the collection by removing all null entries
Iterator<?> iterator = collection.iterator();
while (iterator.hasNext()) {
    if (iterator.next() == null) {
        iterator.remove();
return collection;
voidclear(Collection collection)
A null-safe way to clear a collection that might not be initialized
if (collection != null)
    collection.clear();
Collectionclear(Collection collection)
Removes all elements from the given collection.
if (collection != null) {
    collection.clear();
return collection;
voidclear(Collection collection)
clear
if (collection != null) {
    collection.clear();
voidclear(final Collection collection)
clear
if (isNotEmpty(collection)) {
    collection.clear();
voidclearAndAddAll(final Collection where, final Collection fromWhere)
clear And Add All
if (where == fromWhere) {
    return;
where.clear();
if (!isEmpty(fromWhere)) {
    where.addAll(fromWhere);
voidclearCollection(Collection collection)
clear Collection
if (collection != null) {
    collection.clear();