In this exercise, you will continue building the ArrayListSet class by completing the add() method. This method adds an element to the...
X1363: ArrayListSet - add()
In this exercise, you will continue building the ArrayListSet
class by completing the
add() method. This method adds an element to the
end of the instance variable set (of type ArrayList) that you created in the
previous exercise. Worthy of note, a set does not allow
duplicates. So, your add() method should check if the
element is already in the set. If it is, then
don't add it (do nothing) and return false.
If it is not in the set, then add it and return
true.
You might want to look at the documentation for
ArrayList
to refresh your memory of how to use that class.
Your Answer:
Feedback
Your feedback will appear here when you check your answer.