Create List containing n Copies of Specified Object Example
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
publicclass Main {
publicstaticvoid main(String[] args) {
List list = Collections.nCopies(5, "A");
Iterator itr = list.iterator();
while (itr.hasNext())
System.out.println(itr.next());
}
}
/*
A
A
A
A
A
*/