Using vectors/arrays in xwiki

Hi,
I have this code for displaying all objects of type XWiki.ResultsClass:

## this will display the value of a property for object obj (which is a String or Number)
#foreach($obj in $mydoc.getObjects("XWiki.ResultsClass"))
  #set($discard = $mydoc.use($obj))
  #foreach($prop in $class.properties)
    $mydoc.display($prop.getName())  ## line 4
  #end
#end

I want to change line 4 such that those values to be saved in a vector (array) and than to go through the vector for use that values for different operations.
How can I do this?

Maybe this could help:

#set ($array = [])
#foreach($obj in $mydoc.getObjects("XWiki.ResultsClass"))
  #set($discard = $mydoc.use($obj))
  #foreach($prop in $class.properties)
    #set ($discard = $array.add($mydoc.display($prop.getName()))
  #end
#end
Here the results: $array

Guillaume