Josh Borg wrote:I solved with brute force:...
Which is almost always the
wrong way to go.
You actually have more than one problem at play here:
1. Your ArrayList is not
typed.
2. You are adding the List to your clone instead of its
elements.
And the two are linked. If your List had been properly typed, you would never have been able to
make the second mistake. As for point 2, I suggest you look at the
addAll() method of java.util.List.
And just FYI, there is a third problem: You are using Strings to define food items, which is not generally a good idea. It may be OK for a simple scenario, but it's likely to run you into trouble if you ever decide to do anything more sophisticated. For more info you can read the
StringsAreBad page.
HIH
Winston