Java examples for Collection Framework:Collections Utility Methods
Create List containing n Copies of Specified Object
import java.util.Collections; import java.util.List; import java.util.Iterator; public class Main { public static void main(String[] args) { List list = Collections.nCopies(5,"A"); //from ww w.j av a 2s . co m System.out.println("List contains, "); Iterator itr = list.iterator(); while(itr.hasNext()) System.out.println(itr.next()); } }