I am trying to create a program where the user inputs animal pertinent values, which then create animal Objects, which are then saved into an array list. The area I am having trouble with is shown below. After the Array list is populated, I cannot figure out how to use the user input (select) to find that values index within the array list. (int index = animalList.indexOf(?))
Would appreciate any help
Scanner in = new Scanner(System.in);
List <Animal> animalList = new ArrayList <Animal>();
char ans;
do{ // User input
Animal animal = new Animal(); // arraylist
System.out.println("Animal's 'common' name: ");
animal.setName(in.next());
System.out.println("Animal's class: ");
animal.setAnmlClass(in.next());
System.out.println("Vertabrate or Invertabrate: ");
animal.setCharVert(in.next());
System.out.println("Warm or Cold blooded: ");
animal.setCharBld(in.next());
System.out.println("Animal's habitat (general): ");
animal.setCharHab(in.next());
System.out.println("Would you like to enter in a new animal (y/n)? ");
String answer = in.next();
ans = answer.charAt(0);
animalList.add(animal);
}while(ans == 'y');
System.out.println("Enter the animal you wish to view: ");
String select = in.next();
System.out.println(select);
int index = animalList.indexOf( ? );
System.out.println(index);
Animal.equal().Animalclass have overriddenequals()based onname?