|
|
|
|
The
Here is our previous example that used ArrayList, changed to using HashSet. The example only uses the Iterator approach to obtaining the elements from the collection, because there is no inherent ordering in a Set. Note that I have added an additional call to add, which attempts to add a duplicate element for Frank.
It outputs the following: Vanessa Joe Frank Mary Sylvia which shows that no duplicate element was added. It also shows that the contents are returned in no particular order.
|
|
This page was last modified on 02 October, 2007 |