Source Code : Set Example 1

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Set Example 1

import org.apache.commons.collections.set.MapBackedSet;

import java.util.Map;
import java.util.Set;
import java.util.HashMap;
import java.util.Iterator;

public class SetExampleV1 {
  public static void main(String args[]) {
    // create a Map
    Map map = new HashMap();
    map.put("Key1", "Value1");

    // create the decoration
    Set set = MapBackedSet.decorate(map);

    map.put("Key2", "Any dummy value");
    set.add("Key3");

    Iterator itr = set.iterator();

    while(itr.hasNext()) {
      System.err.println(itr.next());
    }

  }
}
           
       

Thank with us