posted 10 years ago
Greetings,
I'm trying to create an Observable ListOfItems which will contain a list of Items. Each item will have two attributes - name and price. ListOfItems has an observer that is updated whenever there is a change in the observable- i.e whenever there is a new item added to or an existing item removed from the ListOfItems object. My code is as follows.
When I run the TestObservers class, I get the following output.
run:
Item{name=Cheese, price=10.0}
Item{name=Cheese, price=10.0}
BUILD SUCCESSFUL (total time: 0 seconds)
But I have added only one Item to my list. Why am I getting two Items? Shouldn't I get only one Item? Please advise.
Thanks,
Chan.