Example usage for java.util Hashtable Hashtable

List of usage examples for java.util Hashtable Hashtable

Introduction

In this page you can find the example usage for java.util Hashtable Hashtable.

Prototype

public Hashtable() 

Source Link

Document

Constructs a new, empty hashtable with a default initial capacity (11) and load factor (0.75).

Usage

From source file:Main.java

public static void main(String[] s) {
    Hashtable<String, String> table = new Hashtable<String, String>();
    table.put("key1", "value1");
    table.put("key2", "value2");
    table.put("key3", "value3");

    System.out.println(table.contains("value3"));

}

From source file:Main.java

public static void main(String[] args) {
    Hashtable<String, String> ht = new Hashtable<String, String>();

    ht.put("1", "One");
    ht.put("2", "Two");
    ht.put("3", "Three");
    ht.clear();/*from   ww  w  . ja v a2 s.  co m*/
    System.out.println(ht.size());
}

From source file:Main.java

public static void main(String[] args) {
    Hashtable<String, String> ht = new Hashtable<String, String>();
    ht.put("1", "One");
    ht.put("2", "Two");
    ht.put("3", "Three");

    boolean blnExists = ht.containsKey("2");
    System.out.println("2 exists in Hashtable ? : " + blnExists);
}

From source file:Main.java

public static void main(String[] s) {
    Hashtable<String, String> table = new Hashtable<String, String>();
    table.put("key1", "value1");
    table.put("key2", "value2");
    table.put("key3", "value3");

    System.out.println(table.isEmpty());
    System.out.println(table.size());
}

From source file:Main.java

public static void main(String[] s) {
    Hashtable<String, String> table = new Hashtable<String, String>();
    table.put("key1", "value1");
    table.put("key2", "value2");
    table.put("key3", "value3");

    table.clear();//from   ww w .j  a v  a 2 s  .  co m

    System.out.println(table);
}

From source file:Main.java

public static void main(String[] args) {
    Hashtable<String, String> ht = new Hashtable<String, String>();

    ht.put("1", "One");
    ht.put("2", "Two");
    ht.put("3", "Three");

    boolean blnExists = ht.contains("Two");
    System.out.println("Two exists in Hashtable ? : " + blnExists);
}

From source file:Main.java

public static void main(String[] s) {
    Hashtable<String, String> table = new Hashtable<String, String>();
    table.put("key1", "value1");
    table.put("key2", "value2");
    table.put("key3", "value3");

    table.remove("key1");

    System.out.println(table);//from w ww.  j  a  v  a  2 s  .  c om
}

From source file:Main.java

public static void main(String[] s) {
    Hashtable<String, String> table = new Hashtable<String, String>();
    table.put("key1", "value1");
    table.put("key2", "value2");
    table.put("key3", "value3");

    Hashtable tableCopy = (Hashtable) table.clone();

    System.out.println(tableCopy);

}

From source file:Main.java

public static void main(String[] args) {
    Hashtable<String, String> ht = new Hashtable<String, String>();

    System.out.println("Size of Hashtable : " + ht.size());

    ht.put("1", "One");
    ht.put("2", "Two");
    ht.put("3", "Three");

    System.out.println(ht.size());

    Object obj = ht.remove("2");

    System.out.println(ht.size());
}

From source file:Main.java

public static void main(String[] s) {
    Hashtable<String, String> table = new Hashtable<String, String>();
    table.put("key1", "value1");
    table.put("key2", "value2");
    table.put("key3", "value3");

    Hashtable<String, String> table2 = new Hashtable<String, String>();
    table2.put("key4", "value4");
    table2.put("key5", "value5");
    table2.put("key6", "value6");

    table2.putAll(table);/*from w ww.j av a2 s .  c  o  m*/

    System.out.println(table2);
}