20 Ağustos 2009 Perşembe

HashTables

This example creates a hashtable of numbers. It uses the names of the numbers as keys:

Hashtable numbers = new Hashtable();
numbers.put("one", new Integer(1));
numbers.put("two", new Integer(2));
numbers.put("three", new Integer(3));


To retrieve a number, use the following code:

Integer n = (Integer)numbers.get("two");
if (n != null) {
System.out.println("two = " + n);
}

Hiç yorum yok: