Here you can find the source of cleanup(AnyCollection collection)
Parameter | Description |
---|---|
AnyCollection | the type of collection |
collection | the collection |
public static <AnyCollection extends Collection<?>> AnyCollection cleanup(AnyCollection collection)
//package com.java2s; //License from project: Open Source License import java.util.Collection; import java.util.Iterator; public class Main { /**/* ww w.j a v a2 s . co m*/ * Cleanups the collection by removing all null entries * * @param <AnyCollection> the type of collection * @param collection the collection * @return the same collection for chaining calls */ public static <AnyCollection extends Collection<?>> AnyCollection cleanup(AnyCollection collection) { Iterator<?> iterator = collection.iterator(); while (iterator.hasNext()) { if (iterator.next() == null) { iterator.remove(); } } return collection; } }