3:11 pm - Tuesday November 23, 6421

Hashtable Example program for 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
// Hashtable Example program for putAll(Map t)
/**
@author: candidjava.com
@description: This method is used to copy all of the mapping elements to the specified  Hashtable.
*/
import java.util.*;
class Case {
public static void main(String[] args) throws Exception {
Map m = new HashMap(); // create a new map
m.put(1, "X"); // add elements to it
m.put(2, "Y");
Hashtable h1 = new Hashtable(); // create a hashtable
h1.putAll(m); // copy all elements from m to h1
System.out.println(h1);
}
}
<span style="color: #3366ff;">
</span>

Output:
{2=Y, 1=X}

BACK

Filed in: Z-A All Java Codes

Comments are closed.