11:18 pm - Sunday February 19, 2017

Add all data to Hashtable from another Map void putAll(Map t)

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 method copies all the mappings from the map to the hashtable.

Example Program


import java.util.Hashtable;

public class HashtablePutAll 

{

	public static void main(String args[])

	{

		Hashtable htable1 = new Hashtable();

		Map map = new HashMap();

		map.put("1", "Add");

		map.put("2", "Sub");

		map.put("3", "Mul");

		System.out.println("Initial hash table value: " + htable1);

		System.out.println("Map values: " + map);

		htable1.putAll(map);

		System.out.println("Hash table value after put all: " + htable1);

	}

}


Output

       Initial hash table value: {}

       Map values: {3=Mul, 2=Sub, 1=Add}

       Hash table value after put all: {3=Mul, 2=Sub, 1=Add}

 

BACK

Filed in: Java Examples

Comments are closed.