Java tutorial
//package com.java2s; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class Main { public static <T> void clear(List<T> list) { if (list == null) { list = new ArrayList<T>(); } else { list.clear(); } } public static <K, V> void clear(Map<K, V> map) { if (map == null) { map = new HashMap<K, V>(); } else { map.clear(); } } }