Java LinkedHashSet class

Introduction

Java LinkedHashSet implements Set interface and maintains the insertion order.

import java.util.LinkedHashSet;
import java.util.Set;

public class Main {
  public static void main(String[] args) {
    Set<Integer> lhashSet = new LinkedHashSet<Integer>();
    /*from  w  w  w .  j a  va 2 s  .c o  m*/
    lhashSet.add(1);
    lhashSet.add(2);
    lhashSet.add(3);

    System.out.println(lhashSet);

    boolean blnRemoved = lhashSet.remove(2);

    System.out.println(blnRemoved);
    System.out.println(lhashSet);
  }
}



PreviousNext

Related