remove in  Java LinkedHashSet Example

remove in Java LinkedHashSet Example


Posted in : Java Posted on : December 8, 2010 at 5:35 PM Comments : [ 0 ]

This Java Example shows how to remove specific elements which exists in LinkedHashSet.

remove in  Java LinkedHashSet Example

This Java Example shows how to remove specific elements which exists in LinkedHashSet. To remove elements exists in LinkedHashSet We use remove() method of LinkedHashSet class.  It removes the specified element stored in the specified object within the collection.

Example:- RemoveInLinkedHashSet.java

package devmanuals.com;

import java.util.*;

public class RemoveInLinkedHashSet {
	public static void main(String args[]) {

		LinkedHashSet LHSet = new LinkedHashSet();
		LHSet.add("C");
		LHSet.add("A");
		LHSet.add("B");
		LHSet.add("E");
		LHSet.add("F");
		LHSet.add("D");
		System.out.println("The LinkedHashSet elements are: " + LHSet);
		boolean bl = LHSet.remove("B");
		boolean b2 = LHSet.contains("B");
		System.out.println("Is Gyan exists? :" + b2);
		System.out.println("The Elements are: " + LHSet);

	}
}

Output:-

The LinkedHashSet elements are: [C, A, B, E, F, D] 

Is Gyan exists? : false 

The Elements are: [C, A, E, F, D]

Download The Code

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics