When I added my data into the array I used this:
public String[] weDontHave()
{
//I have created a list of items with Status: "i" in-stock, "o" out of //stock
//the number of array elements is dictated by using notOnHand()
String[] out = new String[notOnHand()];
//this counts the number of elements in the array
int size = 0;
for(Node current = head; current != null; current = current.link)
{
if(current.item.getStatus().equals("o) "))
{
//adds the item to the array
out[size] = current.item.getName().toString() + current.Item.getStatus().toString() + current.item.getPrice().toString();
size++;
}
}
return out;
}
So, if I try to print:
System.out.println(out[0]);//I get the correct String printed //if I use System.out.println(out[size]); //I get null //if I use System.out.println(out);//I get the [Ljava.lang.String;@1a758cb repeated //
The testing program that uses a Scanner and user input, I've been given calls (is that the right term?) this method directly from main...
else if (action == 6) System.out.println(inventory.weDontHave()); //when I enter 6, I get [Ljava.lang.String;@1a758cb not the printed array.
I'm sure it's something simple...do I need to write another method?
Thank you in advance for reading this!


Ask A New Question
Reply





MultiQuote






|