 <p>You could use a counter</p> <p>System.out.println("Who do you want to remove?");</p> <pre><code> String name = input.nextLine(); int remove_index = -1; for(int i=0; i&lt;contacts.length; i++){ Contact c = contacts[i]; if(c.getName().equals(name)){ remove_index =i; } } </code></pre>