Add elements in LinkedHashSet

We can use add() method of LinkedHashSet to add elements to LinkedHashSet collection boolean add(Object obj) It adds the element obj to the Set. Example import java.util.*; public class LinkedHashSetAddExample { public static void main(String args[]) {   LinkedHashSet<String> lhs = new LinkedHashSet<String>();   lhs.add("java"); lhs.add("c"); lhs.add("c++"); System.out.println(lhs); } } import java.util.*; public class LinkedHashSetAddExample […]

Share this article on

LinkedHashSet overview

LinkedHashSet is an implementation of Set interface in java Important features of LinkedHashSet It contains only unique elements, does not allow duplicates LinkedHashSet stores elements by using “hashing” mechanism It maintains the insertion order, elements will be stored in the same order as we insert It allows null value, since it allows unique values, only […]

Share this article on
< Previous Next >