filmov
tv
Set Interface in Java | Java Collections | Collection Framwork | Java Tutorial For Beginners

Показать описание
Please use the following link to install the Katalon Studio:
Set:
Set is child interface of Collection.
It is used to represent a group of individual objects as a single entity where duplicates are NOT allowed and insertion order is NOT preserved.
Set doesn’t have any new methods. So, need to use its parent interface methods (i.e. Collection Interface).
Methods defined in Collection Interface:
boolean add(Object o): To add single object to collection.
boolean addAll(Collection c): To add group of objects to collection.
boolean remove(Object o): To remove single object from collection.
boolean removeAll(Collection c): To remove group of objects from collection.
boolean retainAll(Collection c): To remove all objects except those present in c.
void clear(): To clear all the objects from the collection.
boolean contains(Object o): To verify collection contains mentioned object or not?
boolean containsAll(Collection c): To verify collection contains group of objects or not?
boolean isEmpty(): To verify collection is empty or not?
int size(): To get the size(number of objects) of the collection.
Object[] toArray(): Convert collection to an Array.
Iterator iterator(): To get all the elements one by one from the collection.
Set:
Set is child interface of Collection.
It is used to represent a group of individual objects as a single entity where duplicates are NOT allowed and insertion order is NOT preserved.
Set doesn’t have any new methods. So, need to use its parent interface methods (i.e. Collection Interface).
Methods defined in Collection Interface:
boolean add(Object o): To add single object to collection.
boolean addAll(Collection c): To add group of objects to collection.
boolean remove(Object o): To remove single object from collection.
boolean removeAll(Collection c): To remove group of objects from collection.
boolean retainAll(Collection c): To remove all objects except those present in c.
void clear(): To clear all the objects from the collection.
boolean contains(Object o): To verify collection contains mentioned object or not?
boolean containsAll(Collection c): To verify collection contains group of objects or not?
boolean isEmpty(): To verify collection is empty or not?
int size(): To get the size(number of objects) of the collection.
Object[] toArray(): Convert collection to an Array.
Iterator iterator(): To get all the elements one by one from the collection.