Creating/Returning Unknown sized int Array
<p>It's a lot of code I have but here's the relevant bits I think.</p>

<p>I have an array I made of size 10 as a stub, I DO NOT KNOW in advance what size array I might get, only that it cannot be bigger than ten.</p>

<pre><code>    int[] arrTracker = new int[10];
    arrTracker = MyLibrary.SearchForABookISBN( true, AShelf, userParsedArr, aUserTitle );

    for ( int j = 0; j &lt; 10; j++)
    {
        pln(AShelf[arrTracker[j]]);

    }
</code></pre>

<p>In the above code in theory once I have my array I loop through it and display the contents (which will be basically where in the MyLibrary object array have I found the book I am searching for.</p>

<p>"userParsedArr" is the user entered ISBN.</p>

<pre><code>public int[] SearchForABookISBN ( boolean aFlag, Book[] anArray, int[] AnISBN, String aTitle ) 
{
    //This one was difficult.

        int length = anArray.length;
        int[] AnotherArr = new int[0];
        int[] AnotherArrTemp = new int[0];
        int[] AnotherArrNew = new int[0];

        boolean UFoundMe = false;

        if ( aFlag == true )
        {
            for ( int i = 0; i &lt; length; i++)
            {
                //Assume we find the ISBN


                if ( ( anArray[i].Title.equals(aTitle) ) )
                {
                    int counter = 0;
                    for ( int j = 0;  j &lt; 9; j++)
                    {
                        if (anArray[i].ISBN[j] == AnISBN[j])
                        {
                            counter++;
                        }
                        else
                        {
                            UFoundMe = false;
                            break;
                        }
                        if ( counter == 9 )
                        {
                            UFoundMe = true;
                        }

                    }
                    if ( UFoundMe == true )
                    {

                        //Create our 'main' tracker at 1 + size of previous array.
                        AnotherArrNew = new int[1 + AnotherArr.length];
                        if ( AnotherArrTemp.length &gt; 0 )
                        {
                            //Copy values into a temp array.
                            //Make a new temp array
                            for ( int m = 0; m &lt; AnotherArr.length - 1; m++ )
                            {
                                AnotherArrNew[m] = AnotherArrTemp[m];
                            }       
                        }           
                        AnotherArrNew[(AnotherArrNew.length) - 1] = i;

                        AnotherArrTemp = new int[AnotherArrNew.length]; 
                        for ( int n = 0; n &lt; AnotherArr.length; n++ )
                        {
                            AnotherArrTemp[n] = AnotherArrNew[n];
                        }                           

                        System.out.println(anArray[i]);
                    }

                }
            }
        }
        return AnotherArrNew;
  }
}
</code></pre>

<p>Basic idea here is that I create some blank arrays, and then once I find a book I create a new array one size larger and toss out the old array, transfer contents to a temp array and then carefully make a backup of what I made before deleting the old new array to make it bigger.</p>

<p>So presumably say I have 10 books, and 3 of them have the same title and ISBN. I expect to return an array of 3, but I don't know that in advance because what if I'm given 20 books and all of them are the same? </p>

<p>Would MyLibrary.SearchForABookISBN( true, AShelf, userParsedArr, aUserTitle ).length work to let me know the size of the array I'm getting in advance? So just declare:</p>

<pre><code>int aLength = MyLibrary.SearchForABookISBN( true, AShelf, userParsedArr, aUserTitle ).length
int[] arrTracker = new int[aLength];
</code></pre>
