8:21 pm - Wednesday October 18, 2017

Convert hashtable to string String toString()

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

BACK

                                          This function returns a string representation of hashtable in the form of set of entries enclosed in braces and separated by commas.

Example Program

import java.util.Hashtable;

public class HashtabletoString

{

	public static void main(String args[])

	{

		Hashtable htable = new Hashtable();

		htable.put(1, "Add");

		htable.put(2, "Sub");

		htable.put(3, "Mul");

		htable.put(4, "Div");

		htable.put(5, "Exp");

		System.out.println("String form of hash table is: " + htable.toString());

	  }

}

Output

         String form of hash table is: {5=Exp, 4=Div, 3=Mul, 2=Sub, 1=Add}

BACK

Filed in: Java Examples

Comments are closed.