I want to create a queue of Strings that will have many identical elements in it (I’m simulating a set of program instructions). Is there any way to create this collection all at once with a single statement?
myQueue.addAll(create collection of x strings);
Otherwise, I’ll obviously have to loop x times and call myqueue.add(String) x times.
Just wondering if there is a one-line instead of 3-line way to do this…
Thanks!
Collections.nCopies(int n, T o)returns aList<T>containingncopies of the given objecto.