Here you can find the source of clear(Collection
public static <T> void clear(Collection<T> collection)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static <K, V> void clear(Map<K, V> map) { if (map != null) { map.clear();/* w ww . j av a 2s . c om*/ } } public static <T> void clear(Collection<T> collection) { if (collection != null) { collection.clear(); } } }