Im writing a program about animals. The user is supposed to input animal name and age, if the name already exists in the array list they should get an error and be asked to enter a different name. With they code I currently have I can add the same name several times without getting an error. How do I resolve this problem in the easiest way possible?
Edit: the purpose is not to remove the duplicate, but to warn the user that it already exists and ask them to re-enter the name of the animal.
Here is the code: