LinkedHashset with looping

In this article, we will see how to loop LinkedHashset in java Its very much common requirement to iterate or loop through LinkedHashset in java applications There are mainly 2 ways to loop through LinkedHashset in java 1) Enhanced For loop 2) Iterator Let’s see each of these ways with an example 1) Enhanced For […]

Share this article on

Remove LinkedHashSet elements

We can use remove() method of LinkedHashSet to remove elements from LinkedHashSet collection boolean remove(Object obj) Example import java.util.*; public class LinkedHashSetRemoveExample { public static void main(String args[]) {   LinkedHashSet lhs = new LinkedHashSet();   lhs.add(“java”); lhs.add(“c”); lhs.add(“c++”); System.out.println(“LinkedHashSet before removing elements”); System.out.println(lhs); lhs.remove(“java”); System.out.println(“LinkedHashSet after removing elements”); System.out.println(lhs); } } import java.util.*; public […]

Share this article on
< Previous Next >