<p>I have a Java array such as: </p>

<pre><code>String[] arr = new String[] {"123","doc","projectReport.doc"};
</code></pre>

<p>In my opinion the natural way to access would be: </p>

<pre><code> #set($att_id = $arr[0])
 #set($att_type = $arr[1])
 #set($att_name = $arr[2])
</code></pre>

<p>But that it is not working. I have come with this workaround. But it a bit too much code for such an easy task. </p>

<pre><code>#set($counter = 0)
#foreach($el in $arr)
    #if($counter==0)
        #set($att_id = $el)
    #elseif($counter==1)
        #set($att_type = $el)
    #elseif($counter==2)
         #set($att_name = $el)
    #end
    #set($counter = $counter + 1)
#end
</code></pre>

<p>Is there any other way?</p>

You could wrap the array in a
```
List
```
using
```
Arrays.asList(T... a)
```
.  The new List object is backed by the original array so it doesn't wastefully allocate a copy.  Even changes made to the new List will propagate back to the array.
Then you can use
```
$list.get(int index)
```
to get your objects out in Velocity.
If you need to get just one or two objects from an array, you can also use
```
Array.get(Object array, int index)
```
to get an item from an array.