0

For some reason this is only returning the description of a single item in the HashSet even when there are several items. I am not sure if the (Item)iter.next() is only getting the description of the first item in the list and that is why.

    /**
     * 
     */
    public String getMyItemsDescription()
    {
        String returnString = "The items in your inventory are:";
        for(Iterator iter = myItems.iterator(); iter.hasNext();){
            returnString = " " + ((Item)iter.next()).getDescription();
        }
        return returnString;
    }
2
Contributors
1
Reply
9
Views
3 Years
Discussion Span
Last Post by JamesCherrill
0

returnString = " " + ((Item)iter.next()).getDescription();
discards any orevious data in returnString.
How about
returnString = returnString + " " + ((Item)iter.next()).getDescription();
top keep the existing values

This question has already been answered. 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.