Set Interface
Advertisements
Set Interface in Java
Set is an Interface in java API which extends Collection Interface. It is used to store multiple objects with unique that means it do not allows to store duplicate elements. Set Interface are implemented in following collection classes.
- HashSet
- TreeSet
- LinkedHashSet
Note: Set is based on Set in general mathematics which also do not store duplicate elements so here Set Interface do not allows to store duplicate elements.
Create object for Set Implementer classes
Syntax
Set_Implemented_class<generic_class> obj=new Set_Implemented_class<generic_class>();
Example to create object of HashSet
HashSet<String> obj=new HashSet<String>();
Google Advertisment