// MODULE: HashTableTest.java // AUTEUR: felipe // OBJET: utilisation d'une Hashtable import java.util.*; // ------------------------------------------------------- // une classe de travail // ------------------------------------------------------- class Personne { private int age; private String nom, prenom; public int hashCode() { return (11 * nom.hashCode()) + (13 * prenom.hashCode()) + age; } /* public boolean equals(Object o) { if (o instanceof Personne) return (this.prenom.equals(((Personne)o).prenom)) && (this.nom.equals(((Personne) o).nom)) && (this.age == ((Personne) o).age); return false; } */ public Personne(String prenom, String nom, int age) { this.nom = nom; this.prenom = prenom; this.age = age; } public String toString() {return prenom + " " + nom + " age: " + age;} } // ------------------------------------------------------- // voici la classe principale // ------------------------------------------------------- public class HashTableTest { static String epicerie [] = { "abricot","banane","carotte","date","fenouille", "grenade","haricot","jujube","lentilles","myrtilles", "olive","poire","pomme","reglisse","tilleul" }; public static void main( String args [] ) { Hashtable ht = new Hashtable (); String old; Object objetRef; // ajout dans uen hashtable for (int i=0; i