Set Interface implemented classes In Java
Set in Java
The second interface is Set which is extend the collection. Set interface is a unique interface and not maintain any order. Means In the Set interface duplicate values cannot be stored.
- Set is an another interface which continues Collection. It holds an unordered collection of objects in which duplicate/repeated values not allowed.
- Implementation classes of the set interface are HashSet, LinkedSet or TreeSet.
// Java code for adding elements in Set import java.util.*; public class Set_example{ public static void main(String[] args) |
Output:
Set output without the duplicates[Tom, Jerry]
Note: As we know that duplicate now allow in set “Tom” is ignored in the final output, Set interface doesn’t allow duplicate entries.
Now we will see some of the implemented classes and their Difference.
post a comment