Using an array in a method that has been created in another method
<p>How do I write a method, that has a parameter integer representing the index, and returns the value the array holds at the specified index. But the array being used has been generated by a previous method. So far I have this:</p>

<pre><code>public static int get(int var)  {

 int[] result = constructArray(arrayA,array B);
    return result[var];
}
</code></pre>

<p>The main method looks like </p>

<pre><code>  public static void main(final String[] args) {

        int[]result = constructArray(arrayA,arrayB);
        System.out.println(Arrays.toString(result));
        int variable = get(2);
        System.out.println(variable);


}
</code></pre>

<p>The method constructArray constructs a different array each time it is called, so when I call the get method I want to use the array that has already been constructed. How can I achieve this?</p>
