String name = appMenu.promptToyName();
Toys tName = searchByToy(name);
System.out.print(tName.format());
private Toys searchByToy(String toyName) {
Toys tName = null;
for(Toys t: toys) {
if (t.getToyName().toLowerCase().contains(toyName.toLowerCase())) {
tName = t;
}
}
return tName;
}
im doing a search of a arrayList toys, that is an abstract class that calls four other classes of Animals, Figures, Puzzles, and BoardGames
when i use the promptToyName, i enter in a toy name that i have stored into the arrayList from a txt file that has hundreds of different toys, i was expecting it to print out the toy called by search with values that contain the keyword Star, instead whenever i get to the for loop (Toys t: toys) .hasNext() comes up null and the program ends.