Mega Code Archive

 
Categories / Java Tutorial / Collections
 

Displaying Hash Table Contents

The Hashtable class overrides the toString() method of the Object class public String toString() import java.util.Hashtable; public class MainClass {   public static void main(String[] s) {     Hashtable table = new Hashtable();     table.put("key1", "value1");     table.put("key2", "value2");     table.put("key3", "value3");     System.out.println(table);   } } {key3=value3, key2=value2, key1=value1}