Java Hashtable.toString()
Syntax
Hashtable.toString() has the following syntax.
public String toString()
Example
In the following code shows how to use Hashtable.toString() method.
import java.util.Hashtable;
/* w w w . j a v a2s . c om*/
public class Main {
public static void main(String args[]) {
// create hash table
Hashtable<Integer,String> htable1 = new Hashtable<Integer,String>();
// put values in table
htable1.put(1, "A");
htable1.put(2, "B");
htable1.put(3, "C");
htable1.put(4, "from java2s.com");
System.out.println("String form of hash table is: "+htable1.toString());
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »