How to condense this code?
<p>I received some code and I am trying to put it in a better format by condensing it:</p>

<pre><code>ArrayList&lt;Integer&gt; a =  new ArrayList&lt;Integer&gt;();
ArrayList&lt;Integer&gt; c = new ArrayList&lt;Integer&gt;();

for(int i = 0; i &lt; 10; i++) {

    int nextInt = rand.nextInt();

    while((a.contains(nextInt) ? 1:0) + ((nextInt &lt; 0) ? 1:0) + 
                                        ((nextInt &gt; 1000) ? 1:0) &gt;= 1){
        nextInt = rand.nextInt();
    }

    a.add(nextInt);

    nextInt = rand.nextInt();   

    while(((c.contains(nextInt))?1:0) + ((nextInt &lt; 0)?1:0) +
                                        ((nextInt &gt; 1000)?1:0) &gt;= 1) {
        nextInt = rand.nextInt();               
    }

    c.add(nextInt); 
}
</code></pre>

<p>In the while loop there is quite the same code but I wonder if the randomness will be lost if I merge it. However the while condition seems very strange to me; can anyone explain it? How would you condense this code?</p>
