About Lesson
Abstract Set
In Java, the AbstractSet class is the part of the Java Collection Framework. The Abstract list is implemented by the collection interface and the Abstract Collection class. The AbstractSet class does not override the AbstractCollection class but can implement equals()
and hashCode()
method.
Below is the class Hierarchy
Syntax:
Example:
Â
S.no. | Method | Description |
---|---|---|
1 | add(E e) | It is used to add an element to the end of the Set. |
2 | clear() | It is used to remove all the elements from the Set. |
3 | equals(Object o) | It is used to compare an element from another element in the Set. |
4 | hashCode() | It is used to get hash code from the Set. |
5 | Iterator() | It returns all the elements from the Set. Using Iterator. |
6 | listIterator() | It is used to get the Iterated Set in a proper sequence. |
7 | remove(int index) | It is used to remove the specified element from the Set. |
Example:
Â