Hast Table - Dictionary Learn programming Java

Lesson:

Dynamic Memory Management


Exercise:

Hast Table - Dictionary


Objetive:

Submit your dictionary here using a hash table.


Code:

package TableHash;
import java.util.*;
public class Main
{
	static void main(String[] args)
	{
		Hashtable myList = new Hashtable();

		myList.put("white", "blanco");
		myList.put("black", "negro");

		System.out.println("The size is: " + myList.size());

		System.out.println("Contenido:");
		IDictionaryEnumerator miEnumerador = myList.entrySet().iterator();

		while (miEnumerador.MoveNext())
		{
			System.out.printf("%1$s = %2$s" + "\r\n", miEnumerador.Key, miEnumerador.Value);
		}

		if (myList.containsKey("orange"))
		{
			System.out.println(myList.get("orange"));
		}
	}
}

Juan A. Ripoll - Systems Tutorials and Programming Courses ©  All rights reserved.  Legal Conditions.