Advice on Java program
<p>My java project required that I create an array of objects(items), populate the array of items, and then create a main method that asks a user to enter the item code which spits back the corresponding item.</p>

<p>It took me a while to figure out, but I ended up "cheating" by using a <strong>public variable</strong> to avoid <strong>passing/referencing</strong> the object between classes. </p>

<p>Please help me properly pass the object back.</p>

<p>This is the class with most of my methods including <strong>insert</strong> and the <strong>find</strong> method.</p>

<pre><code>public class Catalog {
    private Item[] itemlist;
    private int size;
    private int nextInsert;
    public Item queriedItem;

    public Catalog (int max) {

        itemlist = new Item[max];
        size = 0;
    }
    public void insert (Item item) {
        itemlist[nextInsert] = item;
        ++nextInsert;
        ++size;
    }
    public Item find (int key) {
        queriedItem = null;

        for (int posn = 0; posn &lt; size; ++posn) {
            if (itemlist[posn].getKey() == key) queriedItem = itemlist[posn];
        }{
            return queriedItem;
        }
    }
}
</code></pre>

<p>This is my main class:</p>

<pre><code>import java.util.*;

public class Program {
    public static void main (String[] args) {

        Scanner kbd = new Scanner (System.in);
        Catalog store;
        int key = 1;

        store = new Catalog (8);
        store.insert(new Item(10, "food", 2.00));
        store.insert(new Item(20, "drink", 1.00));



        while (key != 0) {

            System.out.printf("Item number  (0 to quit) ?%n");
            key = kbd.nextInt();
            if (key == 0) {
                System.out.printf("Exiting program now!");
                System.exit(0);
            }

            store.find(key);

            if (store.queriedItem != null) {
                store.queriedItem.print();
            }
            else System.out.printf("No Item found for %d%n", key);

        }
    }
}
</code></pre>

<p>Thanks I appreciate the help!!!!!!</p>
