Hashtable values Example


Hashtable class values example. public Collection values() Returns a Collection view of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. If the map is modified while an iteration over the collection is in progress (except through the iterator's own remove operation), the results of the iteration are undefined.

Here is the code

/**
 * @ # Clear.java
 * A class repersenting use to clear method 
 * of HashMap class in java.util package
 * version 19 May 2008
 * author Rose India 
 */
import java.util.*;

public class Values {

    public static void main(String[] args) {
        Hashtable table = new Hashtable();

        //Put value into the table
        table.put(1"A");
        table.put(2"B");
        table.put(3"C");
        table.put(4"D");

        //Get all values of the table
        System.out.println("values of table :" + table.values());
    }
}

Output
 values of table :[D, C, B, A]

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

HOME | COPYRIGHT | CONTACT US