Hashtable

Una Hashtable, tabla hash, es una implementación concreta de un Dictionary. Se puede utilizar una instancia de Hashtable para almacenar objetos arbitrarios que están indexados por cualquier otro objeto arbitrario. La utilización más habitual de una Hashtable es utilizar un String como clave para almacenar objetos como valores. El ejemplo java818.java, crea una tabla hash para almacenar información acerca del Tutorial.import java.util.Dictionary;
import java.util.Hashtable;
class java818 {
public static void main( String args[] ) {
Hashtable ht = new Hashtable();

ht.put( "titulo","Tutorial de Java" );
ht.put( "autor","Agustin Froufe" );
ht.put( "email","froufe@arrakis.es" );
ht.put( "patria","Spain" );
ht.put( "edad",new Integer( 31 ) );
show( ht );
}
static void show( Dictionary d ) {
System.out.println( "Titulo: " + d.get( "titulo" ) );
System.out.println( "Autor: " + d.get( "autor" ) );
System.out.println( "E-mail: " + d.get( "email" ) );
System.out.println( "Pais: " + d.get( "patria" ) );
System.out.println( "Edad: " + d.get( "edad" ) );
}
}

0 comentarios:

 


japam abiuk - Templates Novo Blogger 2008