Cloning Hash Map: public Object clone() : HashMap « Collections « Java Tutorial

Java Tutorial
1. Language
2. Data Type
3. Operators
4. Statement Control
5. Class Definition
6. Development
7. Reflection
8. Regular Expressions
9. Collections
10. Thread
11. File
12. Generics
13. I18N
14. Swing
15. Swing Event
16. 2D Graphics
17. SWT
18. SWT 2D Graphics
19. Network
20. Database
21. Hibernate
22. JPA
23. JSP
24. JSTL
25. Servlet
26. Web Services SOA
27. EJB3
28. Spring
29. PDF
30. Email
31. J2ME
32. J2EE Application
33. XML
34. Design Pattern
35. Log
36. Security
37. Apache Common
38. Ant
39. JUnit
Java
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Tutorial » Collections » HashMap 
9. 26. 26. Cloning Hash Map: public Object clone()
import java.util.HashMap;

public class MainClass {
  public static void main(String[] a) {

    HashMap map = new HashMap();
    map.put("key1""value1");
    map.put("key2""value2");
    map.put("key3""value3");

    HashMap map2 = (HashMap)map.clone();
    System.out.println(map2);
  }
}
{key1=value1, key3=value3, key2=value2}
9. 26. HashMap
9. 26. 1. HashMap Class: a basic key-value map where the elements are unordered
9. 26. 2. Iterate through the values of HashMap
9. 26. 3. Get Synchronized Map from HashMap
9. 26. 4. Check if a particular key exists in HashMap
9. 26. 5. Check if a particular value exists in HashMap
9. 26. 6. For keys of a map
9. 26. 7. For values of a map
9. 26. 8. For both the keys and values of a map
9. 26. 9. Storing Primitive Types in a Collection
9. 26. 10. Get Set view of Keys from HashMap
9. 26. 11. Get Size of HashMap
9. 26. 12. Adding Key-Value Pairs: public Object put(Object key, Object value)
9. 26. 13. If key is not in add the key value pair
9. 26. 14. Unlike a Hashtable, both the key and the value for a HashMap can be null
9. 26. 15. To copy all the key-value pairs from one Map into another: public void putAll(Map map)
9. 26. 16. Displaying Contents: public String toString()
9. 26. 17. Remove value from HashMap
9. 26. 18. Removing Key-Value Pairs: public Object remove(Object key)
9. 26. 19. Removal of all elements from a map: public void clear()
9. 26. 20. Sizing Hash Maps: find out the number of key-value pairs within the HashMap
9. 26. 21. Fetching Keys and Values: find a value based upon a specific key with: public Object get(Object key)
9. 26. 22. Getting the set of all keys with the keySet() method: public Set keySet()
9. 26. 23. To get the set of all the values in the hash map: public Collection values()
9. 26. 24. To get a set of Map.Entry elements back from a HashMap: public Set entrySet()
9. 26. 25. Finding Elements
9. 26. 26. Cloning Hash Map: public Object clone()
9. 26. 27. Creating a Copy of a Collection: the objects are not cloned.
9. 26. 28. Checking Hash Maps for Equality: public boolean equals(Object o)
9. 26. 29. Sort an HashMap based on the keys
9. 26. 30. Serializing Hash Maps
9. 26. 31. Use Iterator to loop through the map key set
9. 26. 32. Create Java Hashtable from HashMap
9. 26. 33. How do I...Store simple pairs of data for quick lookup?
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.