How to prevent a user from duplicating an entry (Java)
<p>I am writing a simple program where the user enters a name and an integer.  If the integer was not already used, the name goes into an array.  My problem is that I can't seem to figure out how to check the integer when it is entered to see if it was already used (duplicated).  I tried putting the integers into an array, but could not get it to work.  Please keep in mind that I am a complete novice.  So in the code below, after the user enters a name, he/she enters a time (integer) and if the time was not already used, it is valid; if it was used, I'll need to throw an exception.  So far, all I have is the code working for the name (adding it to the array).</p>

<pre><code>public void enterName()
{

    Scanner keyboard = new Scanner(System.in);

    for(i = 0; i &lt; arrayNames.length; i++)
    {           
        System.out.println("Please enter your name.");
        names = keyboard.nextLine();

            arrayNames[i] = names;              
            System.out.println("name is in");           
    }
    System.out.println("array is full");


}
</code></pre>
