Java tutorial
//package com.java2s; import java.util.*; public class Main { public static <T> Collection<T> defaultCollection(Collection<T> col, int size, T defaultValue) { try { col.clear(); } catch (Exception e) { } for (int i = 0; i < size; i++) { col.add(defaultValue); } return col; } }