
import java.util.*;

class CompterMotsAvecHashtable {

    public static void main(String args[]) {
        StringTokenizer st = new StringTokenizer("this is this test");
	Hashtable hashtable = new Hashtable();
        while (st.hasMoreTokens()) {
            String cle = st.nextToken();
	    if (!hashtable.containsKey(cle)) {
		hashtable.put(cle, new Integer(1));
	    } else {
		Integer nbOccurences = (Integer) hashtable.get(cle);
		hashtable.put(cle, new Integer(nbOccurences.intValue()+1));
	    }
	}
	Enumeration enum = hashtable.keys();
	while(enum.hasMoreElements()) {
	    String cleCourante = (String) enum.nextElement();
	    System.out.print("("+hashtable.get(cleCourante)+","+cleCourante+") ");
	}
	System.out.println();
    }
}
