Java 8 - what is the correct way to fill an arraylist with the same object using Stream API?
<p>I am new with Stream API and I am looking for more elegant and shortest way to fill an ArrayList <strong>with the same object</strong> using Stream API equivalent to this code:</p>

<pre><code>SomeObject someObject = new SomeObject();
List&lt;SomeObject&gt; someObjectList = new ArrayList&lt;&gt;();

int maxLimitValue = 70; //for example
for(int i=0; i&lt;=maxLimitValue; i++){
   someObjectList.add(someObject);
}
</code></pre>

<p>I have seen many different solutions for my current task:</p>

<p><a href="https://stackoverflow.com/a/33142064/5331196">This variant</a> is almost what I want, but there is an auto-generation of the objects, but I need to use the same object created once.</p>

<p><a href="https://stackoverflow.com/a/5600690/5331196">This solution</a> is also almost what I need, but I am no sure about this copying of objects and the returned List type <strong>is not</strong> ArrayList (it returned the CopiesList type, which cannot be added to the ArrayList in the future operations). </p>

<p>p.s. maybe it's possible duplicate, but I really can't find the correct and short way to do this using Stream API.</p>

<p><strong>Update (assylias additions):</strong></p>

<p>Yes, I agree with you about this variant:</p>

<pre><code>List&lt;SomeObject&gt; list = Collections.nCopies(70, someObject);
</code></pre>

<p>But, when I am opening this method:</p>

<pre><code>public static &lt;T&gt; List&lt;T&gt; nCopies(int n, T o) {
        if (n &lt; 0)
            throw new IllegalArgumentException("List length = " + n);
        return new CopiesList&lt;&gt;(n, o);
    }
</code></pre>

<p>And as we see - it returning the CopiesList object, not ArrayList.
Also, as the other lists, it is extending the AbstractList:</p>

<pre><code>private static class CopiesList&lt;E&gt;
        extends AbstractList&lt;E&gt;
        implements RandomAccess, Serializable
    {
        private static final long serialVersionUID = 2739099268398711800L;

        final int n;
        final E element;

        CopiesList(int n, E e) {
            assert n &gt;= 0;
            this.n = n;
            element = e;
        }
...}
</code></pre>

<p>It's not quite ArrayList, but thank's for your suggestions and advice whithout an empty words and off-topic comments, I will use your solution.</p>