Java List fill specified object
import java.util.Collections; import java.util.List; public class Main { public static void main(String[] args) { List<String> list = Collections.nCopies(5, "CSS"); System.out.println(list);//from ww w . j a v a2 s.c o m //the list is read only list list.add("demo 2s.com"); System.out.println(list); } }