0
public String viewByItemCode(String icode)
    {
        String search = " ";
        
        for( ; x<recordNum ; x++)
        {
            if(itemRef[x].getItemCode() == icode)
            {
                search = ("\nItem Code: " +itemRef[x].getItemCode()+ "\nItem Description: " +itemRef[x].getItemDesc()+ "\nItem Unit Price: " 
                        +itemRef[x].getItemUnitPrice()+ "\nItem Quantity: " +itemRef[x].getItemQty()+ "\nItem Unit Measure: " 
                        +itemRef[x].getItemUnitMeasure()+"\n");     
            }       
        }
        return search;
    }

Supposed to return a record placed in a String so I can print it in main, but it doesn't work. :( Help?

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by pringles08
0

what "doesn't work"?

For one you don't define "x" anywhere. If defined outside the method, VERY BAD.

Yes, I defined it outside the method. This is only my second JAVA program. I'm new to JAVA, I have been using C, but my subject in school requires JAVA. Thanks for taking a look. God bless!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.