So, i have ArrayList which i store animals in.
private ArrayList<Animal> catalog = new ArrayList<>();
Now, i need to print the catalog into my output when i press 4 into my output.
case 4:
System.out.println("List of animals: ");
printIt(); //Function to print catalog
break;
I tried to do it with
private boolean InList(String name) {
for (int i = 0; i < catalog.size(); i++) {
if (name.equalsIgnoreCase(catalog.get(i).getName())) {
return true;
}
}
return false;
}
But it's not working. Can you guys help me to get this piece of code?