LinkedHashSet in Java

LinkedHashSet is maintains the insertion(insert the elements) order in Linked List.Elements get Sorted in the sequence order.


We can delete the elements by using remove() method in LinkedHashSet.It is similar to the HashSet and Tree Set but the difference is HashSet doesn’t maintain any order and TreeSet sort the elements in ascending order.

import java.util.*;

class Linkhashset


    public static void main(String args[])


     LinkedHashSet al = new  LinkedHashSet();







     System.out.println(al); //print all the elements

     al.remove("siman"); //remove an element(siman) from the set

     System.out.println(al); //retrieving elements after removing




LinkedHashSet in Java