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");


This is a continuation of your previous post, so you should not create a new topic. Just add to your existing topic.
Printing "not found" inside the loop will print out for every element that does not match.
You need to go through the loop looking for matches.
If you find one, save the value of i in a variable and exit the loop
After the loop check to see if you have saved a value - if so you have found a match, if not you haven't. Now you can print the right message.