WeakHashMap isEmpty Example

WeakHashMap class isEmpty example. This example shows you how to use isEmpty method.


WeakHashMap class isEmpty example.public boolean isEmpty() Returns true if this map contains no key-value mappings. This result is a snapshot, and may not reflect unprocessed entries that will be removed before next attempted access because they are no longer referenced.

Here is the code

/**
 * @ # isEmpty.java
 * A class repersenting use to IsEmpty method 
 * of WeakHashMap class in java.util package
 * version 22 May 2008
 * author Rose India 
 */
import java.util.*;

public class IsEmpty {

    public static void main(String args[]) {
        WeakHashMap map = new WeakHashMap();
        System.out.println("map is empty= " + map.isEmpty());
        map.put(1"A");
        map.put(2"B");
        map.put(3"C");
        map.put(4"D");

        System.out.println("map is empty= " + map.isEmpty());
    }
}

Output
 map is empty= true
map is empty= false

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US