Data Structures Set by using Java

Assoc. Prof. Leon Abdillah

Data Structures Set by using Java

Leon Andretti Abdillah

Data structures set consists of some non-duplicate elements. Set do not allow the same data. Set was implemented in to three sub data structures: 1) HashSet, 2) TreeSet, and 3) LinkedHashSet.

HashSet working with these methods:

Operations Notes
add() Adds the specified element to this set if it is not already present.
clear() Removes all of the elements from this set.
contains() Returns true if this set contains the specified element.
isEmpty() Returns true if this set contains no elements.
remove() Removes the specified element from this set if it is present.
removeAll() Removes from this set all of its elements that are contained in the specified collection (optional operation).
size() Returns the number of elements in this set (its cardinality).


Abdillah, L. A. (2013). Algorithms & Programming. Available:

Abdillah, L. A. (2014). Data Structures & Algorithms. Computer Science for Education, from

Oracle Docs. The Set Interface. The Java Tutorials, from

Leave a Reply

Your email address will not be published. Required fields are marked *