Java LinkedHashSet

Posted in Java Collections By Raj On November 18, 2017


In my previous article, I have explained how HashSet works, the  HashSet does not support maintaining order but The LinkedHasSet supports so,  if you want to retrieve whatever order you have stored then you can very well use LinkedHashSet

The LinkedHashSet class extends HashSet and the below things you need to consider before choosing it

  • The LinkedHashSet maintains order
  • It will not allow duplicate values
  • It allows null values

Output :