Remove All Entries of Java LinkedHashMap Example

Remove All Entries of Java LinkedHashMap Example


Posted in : Java Posted on : December 4, 2010 at 6:13 PM Comments : [ 0 ]

This Java Example shows how to remove all the Entries from the specified Linked HashMap object in java.

Remove All Entries of Java LinkedHashMap Example

This Java Example shows how to remove all the Entries from the specified Linked HashMap object  in java. To remove all of the Entries from Linked HashMap object we use void clear() method. This method removes all of the mappings from this map.

Example: ClearEntriesofLinked HashMap.java

package devmanuals.com;

import java.util.*;

public class ClearEntriesofLinkedHashMap {
	public static void main(String args[]) {
		LinkedHashMap Lhm = new LinkedHashMap();
		Lhm.put(1, "Gyan");
		Lhm.put(6, "Ankit");
		Lhm.put(5, "Arun");
		Lhm.put(4, "Anand");
		Lhm.put(3, "Ram");
		System.out.println("The Size of LinkedHashMap are : " + Lhm.size());
		Lhm.clear();
		System.out.println("The size of map after removal : " + Lhm.size());
		System.out.println("The LinkedHashMap entries is as follows : " + Lhm);
	}
}

Output:

The Size of LinkedHashMap are : 5 

The size of map after removal : 0 

The LinkedHashMap entries is as follows : {}

Download The Code

Go to Topic «PreviousHomeNext»

Your Comment:


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

 
Tutorial Topics