Iterate once and only once through all the possible configurations of an array

Here is an arraylist constructor.

ArrayList<someClass> varName = new ArrayList<someClass>();

To add to the arraylist;

varName.add(someInstanceOfClass);

Read value

VarName.get(int);

Set value

varName.set(int, someInstanceOfClass);