compare two array of string and store the result in another array
<p>I want to compare two arrays and store the difference in another array</p>

<p>For example the two arrays might be</p>

<pre><code>String[] a1 = { "cat" , "dog" };
String[] a2 = { "cat" , "rabbit" };
</code></pre>

<p>The resultant array would be like this</p>

<pre><code>{ "rabbit" }
</code></pre>

<p>I use this code, but it does not work</p>

<pre><code>int n = 0;
for (int k = 0; k &lt;= temp.length; k++)
{
    for (int u = 0; u &lt;= origenal.length; u++)
    {
        if (temp[k] != origenal[u] &amp;&amp; origenal[u] != temp[k])
        {
            temp2[n] = temp[k];
            System.out.println(temp[u]);
            n++;
        }
    }
}
</code></pre>
