currently working on a project for college. when searching coffee names from the array list , it will show the object but will also show "there is no coffee in the list" for every time the object doesn't match the search, how can I sort this out?
public static void search () {
boolean arrayName = false;
if (numberOfCoffees > 0) {
System.out.println ("search coffee");
System.out.println ("what are you searching for?");
String search = sc.nextLine();
for (int i = 0; i < numberOfCoffees; i++) {
arrayName = coffee[i][0].equals (search);
if (arrayName == true) {
System.out.println("coffee found: " + coffee[i][0] + " £" + coffee[i][1] );
} else {
System.out.println ("coffee not found");
}
}
} else {
System.out.println("there is no coffee in the list");
}
}