[Bluej-discuss] Ex.4.38
Mike Stevens
howlinhuskie1 at shaw.ca
Mon Nov 13 06:22:42 GMT 2006
Hi Colleen, I'm not getting it, am I using the right loop here? I've tried
a for each loop also and have had no success. I seems like when it hits my
if loop it just pass's it on by and does nothing. I looked at the rest of
the exercises and have tried everything I can think of and it just won't add
item in. I did create another method to add in just to test and the else
worked System.out.print("Id used");
Any help would be great.
public void addProduct(Product item)
{
Iterator it = stock.iterator();
while(it.hasNext()) {
Product inStock = (Product) it.next();
if(inStock.getID() != item.getID())
{
stock.add(item);
}else{
System.out.print("Id used");
}
}
}
Thanks
Mike
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.bluej.org/pipermail/bluej-discuss/attachments/20061113/6084be07/attachment.html
More information about the bluej-discuss
mailing list