Guide to Set Interface in Java with SortedSet, HashSet, LinkedHashSet and TreeSet Set Interface (java.util.set) Set is part of Collection Framework . Set directly extends Collection interface and uses its capability. Set is unordered data structure and contains only unique values means does not contains duplicate values. Following are child classes and interfaces of Set interface : HashSet Class LinkedHashSet Class SortedSet Interface TreeSet Class HashSet Class : HashSet contains unordered elements and can not contains duplicate elements. How to create new HashSet? Set set = new HashSet() Or HashSet hashSet = new HashSet() Lets see example of HashSet : Example 1 : HashSet class demo import java.util.HashSet; import java.util.Set; public class HashSetDemo { public static void main(String[] args) { Set<String> set = new HashSet<>() {{ add("Java"); add("Java"); add("Python"); add(&quo
Welcome To Programming Tutorial. Here i share about Java Programming stuff. I share Java stuff with simple examples.