A peculiar bug which I can't seem to find
<p>What I'm trying to do is I have this program which reads in a number, and that number designates how many words there are, for example:</p>

<pre><code>3 
red 
blue
green
</code></pre>

<p>And then prints out that same text but in reverse order so it would be</p>

<pre><code>green 
blue 
red
</code></pre>

<p>followed by a blank line indicating to the server that you are done with that specific problem. But I seem to have a bug in my code somewhere.</p>

<p>I tried to store the words in an array List. I used a <code>for</code> loop to store them in the list and then to print them out in reverse order I just used another for loop going the opposite way, starting from the end of the list going to the beginning.</p>

<p>When I run the program from the command prompt it just goes to the next command prompt line as if I had as it to compile the program, there are no errors but when I 
did a test, using a test program I created, it seems that the program reads the number but then goes and prints out a blank array. </p>

<p>It would seem as though the words from the server don't get stored in the array and I'm not sure what I'm doing wrong. I'm not the greatest programmer so any help would greatly be appreciated.</p>

<p>The Code:</p>

<pre><code>import java.io.*;
import java.util.*;

public class Solution
{
    public static void run(BufferedReader in, PrintWriter out)
        throws IOException
    {
        int x = Integer.parseInt(in.readLine());

        while(x != 0)
        {
            ArrayList num  = new ArrayList();

            for(int i = 0; i &lt; num.size(); i++)
            {
                //String f = in.readLine();
                num.add(in.readLine());
            }
            //System.out.println(num);

            for(int i = num.size()-1; i &gt; 0; i--)
            {
                out.println(num.get(i));

                //x = Integer.parseInt(in.readLine());
                System.out.println();
            }
            break;
        }
        out.flush();
    }
}
</code></pre>
