Is there an utility method in Java that generates a list or array of a specified length with all elements equal to a specified value (e.g [\"foo\", \"foo\", \"foo\", \"foo\"
If your object are not immutable or not reference-transparent, you can use
Stream.generate(YourClass::new).limit()
and collect it to list
.collect(Collectors.toList())
or to array
.toArray(YourClass[]::new)