Passing array to array is yielding null values, what have I done wrong?
<p>So I'm trying to write some code where I basically need to expand an array by one every time I pass through a loop. Yes I know that arrays are fixed size and that I need a new array each time. I'm also aware that if I used a list rather than an array I wouldn't be having any issues however I am being forced to use an array.</p>

<p>My code is so:</p>

<pre><code>  public static void getAnimals()
    {
        String animalName[] = new String[1];
        int animalNumber[] = new int[1];
        int lengthOfAnimals;

        animalName[0] = "Null";
        animalNumber[0] = 0;

        while (!animalName[animalName.length - 1].equals("EXTERMINATE"))
        {


            animalName[animalName.length - 1] = JOptionPane.showInputDialog("Name an animal?");
            String numLeft = JOptionPane.showInputDialog("How many are left?");
            animalNumber[animalNumber.length - 1] = Integer.parseInt(numLeft);

            if (animalName[animalName.length - 1].equals("EXTERMINATE"))
            {
                break;
            }

            else
            {

                System.out.println(animalName[animalName.length - 1]);
                animalName = expandName(animalName);
                animalNumber = expandNumber(animalNumber);

            }               
        }




    }

    public static String[] expandName(String animalName[])
    {

        String animalNameExpanded[] = new String[animalName.length + 1];

        for (int a = 0; a &lt;= animalName.length - 1; a++)
        {
            animalNameExpanded[a] =  animalName[a];
        }


        return animalNameExpanded;
    }

    public static int[] expandNumber(int animalNumber[])
    {
        int animalNumberExpanded[] = new int[animalNumber.length + 1];

        for (int a = 0; a &lt;= animalNumber.length - 1; a++)
        {
            animalNumberExpanded[a] =  animalNumber[a];
        }

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

<p>Now when this runs the value that get puts into animalName and animalNumber is now null. What is going on and how do I fix this.</p>
