Utilisation d'une Hashtable
Bonjour tout le monde,
Je souhaiterais avoir un tableau d'entiers indexé par deux chaines de caractères.
J'ai cru comprendre que les hashtable étaient adaptées pour cela. Cependant j'ai un petit problème pour leur utilisation :
Code:
1 2 3 4 5 6 7 8 9
|
Hashtable<String[],Integer> test = new Hashtable<String[],Integer>();
String[] index = new String[] {"a", "b"};
test.put(index, 2);
System.out.println(test.get(index )); // Renvoie 2 (bien)
System.out.println(test.get(new String[] {"a", "b"})); // Renvoie null (pas bien) |
Je souhaiterais pouvoir récupérer la valeur '2' à partir de "a" et "b" uniquement (ie : sans passer par index).
Comment puis-je faire ?
Merci d'avance !