Generating objects and putting into arraylist with no duplicates
<p>Hi I am figuring out why this code is not working the way how i wanted it to work..</p>

<p>What i basically want is a random object that has a char and an int generating and putting it into an arraylist. However if the generated matches the same in the arraylist it must regenerate the number again and check to see if it exists. If it does not exist it will then be added into the arraylist.</p>

<pre><code>    private final char letter;
    private final int num;
    private static Collection&lt;RegistrationNumber&gt; REGISTRATION_NUMBER = new ArrayList&lt;RegistrationNumber&gt;();

    private RegistrationNumber(){
        Random rand = new Random();
        this.num = (1+(rand.nextInt(3)));
        this.letter = Character.toUpperCase((char)(rand.nextInt(1)+'a'));
    }

    public static RegistrationNumber getInstance(){
        boolean foo = false;
        RegistrationNumber rn = null;
        while(!foo){
            rn = new RegistrationNumber();
            if(!REGISTRATION_NUMBER.contains(rn)){
                REGISTRATION_NUMBER.add(rn);
                foo=true;
            }           
        }return rn;
    } 
</code></pre>

<p>Once I look through the arraylist, there are still some repeating for example [A1,A1,A2] or [A2,A2,A3] </p>

<p>Many thanks!</p>
