How to set array elements after I have initialized it?
<p>I am looking for a simple way to set the elements of an array after it is initialized. I have tried this :</p>

<pre><code>package com.ehsan.app;

public class Main {

    public static void main(String[] args) {
        int[] test = new int[6];
        test = {1,2,3,4,5};
    }
}
</code></pre>

<p>However compiling this gives error :</p>

<pre><code>Error:(7, 16) java: illegal start of expression
Error:(7, 17) java: not a statement
Error:(7, 18) java: ';' expected
Error:(9, 1) java: class, interface, or enum expected
</code></pre>

<p>I can use this way to put values in the array:</p>

<pre><code>test[0] = 1;
test[1] = 2;
test[2] = 3;
test[3] = 4;
// and so on.
</code></pre>

<p>I am just looking for a simple way to do that. </p>

<hr/>

<p><strong>Edit</strong></p>

<p>I know I can use this :</p>

<pre><code>int[] test = {1,2,3,4};
</code></pre>

<p>But what I want is a simple way to put values in array after its initialization.</p>

<p>And one another thing : I am not looking for loops!</p>

<p><hr/>
<strong>Edit</strong></p>

<p>The answer @Python gave was what I was looking for!</p>