Java hashmap, hashtable

Java hashmap, hashtable

When are you using hashmap and hashtable?
View Answers

October 26, 2010 at 11:01 AM

Hi,

Here is the answer.

  • The hashMap and Hashtable are differ from each other according to following points-
  • HashMap allows null values for key and value whereas Hashtable doesnt allow.
  • HashMap does not guarantee that the order of the map will remain constant over time.
  • HashMap is non synchronized where as Hashtable is synchronized.
  • HashTable is an Old java class but Hashmap is a new java class in java 2.
  • In HashTable you can change the iteration but in the case of HashMap you can change the iteration but you will get a java.util.ConcurrentModificationException.

Thanks.









Related Tutorials/Questions & Answers:
Java hashmap, hashtable
Java hashmap, hashtable  When are you using hashmap and hashtable
Differences between HashMap and Hashtable?
Differences between HashMap and Hashtable?  Differences between HashMap and Hashtable
Advertisements
Java hashtable
Java hashtable   What is hash-collision in Hashtable and how it is handled in Java
hashtable java swing
hashtable java swing  i m getting this warning code is here Hashtable nu=new Hashtable(); Hashtable ns=new Hashtable(); nu.put(new... mber of the raw type Hashtable plz help me
HashMap in Java
is almost equal to HashTable, the only difference is that HashMap allows null... in the map. Example of Hashmap in Java:ADS_TO_REPLACE_3 package...HashMap class is used to implement Map interface. The value of HashMap
Java collection -Hashtable
Java collection -Hashtable   What is Hashtable in java collection?   Java collection -Hashtable;- The hashtable is used to store value... { public static void main(String [] args){ Map map = new Hashtable
How to find hashtable size in Java?
How to find hashtable size in Java?  Hi, What is the code for Hashtable in Java? How to find hashtable size in Java? Give me the easy code. Thanks
hashtable - Java Beginners
hashtable  pls what is a hashtable in java and how can we use... to Roseindia"); Hashtable hash = new Hashtable(); hash.put("amar","amar"); hash.put...://www.roseindia.net/java/ Thanks. Amardeep
Example of HashMap class in java
Example of HashMap class in java. The HashMap is a class in java collection framwork. It stores values in the form of key/value pair. It is not synchronized
Java Hashmap
Java Hashmap  Java code for below: Any help is appriciated A text file consisting of output of (vid, cid) pairs is given. Suppose that vid is a 6-digit integer and cid is a 3-digit integer. Implement the following methods
Java Hashmap
Java Hashmap  Java code for below: Any help is appriciated A text file consisting of output of (vid, cid) pairs is given. Suppose that vid is a 6-digit integer and cid is a 3-digit integer. Implement the following methods
Doubts regarding Hashtable - Java Beginners
it possible to create a hashtable like this? java.util.Hashtable hashtable=new...(12,13,10,1)); since we get the key of hashtable from the database. When I tried... information, http://www.roseindia.net/java/example/java/util/ Thanks
Hashmap
*; public class HashTable { public static void main(String args[]){ HashMap hm...Hashmap  public class HashTable { public static void main(String args[]){ HashMap hm=new HashMap(); hm.put(new Integer(2), "Two"); hm.put
HASHMAP
HASHMAP  HI CAN WE ADD PRIMITIVE DATA TYPE IN HASHMAP IN JAVA 1.5 VERSION . THANKS KALINS NAIK   Java HashMap Example
Java HashMap example.
Java HashMap example. The HashMap is a class in java. It stores values in name..., you will see how to create an object of HashMap class. How to display vlaue of map. Code:  HashMapExample .java (adsbygoogle
Hashtable java prog - Java Interview Questions
Hashtable java prog  Create a hashtable with some student hall ticket numbers and their results. when we type a hallticket number,it shud display the results? please provide the detail java code for this? thanks in advance
Java Hashmap Sorting - Java Beginners
Java Hashmap Sorting   I have a sorting issue with a Hashmap. My constraint is that I MUST use the Hashmap and work with existing code. I do a database query and place the results in a Hashmap. When I iterate thru the Hashmap
HashMap
HashMap  How to work hashmap and hashset internally
hashmap
hashmap  write a program that shows the use of Hashmap class
HashMap/HashSet - Java Beginners
HashMap/HashSet  im working on a game, and i want to know how does the code for HashMap and HashSet work or can you give me the code that needs to be included in the game engine. I have the exam on monday. Can you please help
Java HashMap iterator and example
Java HashMap Iterator is an interface. It keeps the data in the key and value form. It is implemented by HashMap. hashMap doesnot have iterator method... elements can be traversed by the Iterator. Example of Java HashMap
Hashtable java prog - Java Interview Questions
Hashtable java prog  Create a Hashtable with some students hall... the results? please provide the java code detaily for this query?thanks... bal; Hashtable table = new Hashtable(); table.put( new Integer(1111),"Selected
Hashmap
Hashmap  Hi i want to date and day in hashmap , 1 want to display according to day with date, how to write aprograme
Java hashmap clear() method example.
Java hashmap clear() method example. This tutorial is based on clear() method of java HashMap class. It removes all values from HashMap. Code: ...({}); /* Add values into HashMap */ obMap.put(new Integer(1), "
Java HashMap - Java Tutorials
) { Map m1 = new HashMap(); m1.put("Ankit", "8"); m1.put("Kapil", "31... : C:\Program Files\Java\jdk1.6.0_18\bin>java MapDemo
Java Collection : Hashtable
Java Collection : Hashtable In this tutorial, we are going to discuss one of concept (Hashtable ) of Collection framework. Hashtable  : Hashtable.... When you increase the entries in the Hashtable, the product of the load
HashMap
HashMap  How can you get a HashMap to Display Text onto a Text Field that is defined and Set up to JPanel on a different Class static class public static Map <String, ActionListener> listener = new HashMap <String
Java Hashtable Iterator
be traversed by the Iterator. Java Hashtable Iterator Example import java.util.*; public class hashtable { public static void main(String[] args) { Hashtable hastab = new Hashtable(); hastab.put("a", "andrews
How to get Keys and Values from HashMap in Java?
How to get Keys and Values from HashMap in Java? Example program of iterating... and values from HashMap? This is the most asked questions in the Java... set from a HashMap object and then iterate and print it on console. Check Java
Java Hashmap Iterator
Java HashMap Iterator is a collection class. It implements the Map interface. It keeps the data in the key and value form. Java HashMap has no iterator.... Set's all elements can be traversed by the Iterator. Java Hashmap Iterator
The Hashtable Class
The Hashtable Class In this section, you will learn about Hashtable and its implementation with the help of example. Hashtable is integrated with the collection framework and also implements the Map interface. Similar to HashMap
JSON to HashMap
JSON to HashMap  Hi, How to convert a JSON String to HashMap in Java... it to HashMap. Include following in pom.xml file: <dependency> <... following code for conversion of JSON String to HashMap: String jsonString
ModuleNotFoundError: No module named 'HashTable'
ModuleNotFoundError: No module named 'HashTable'  Hi, My Python... 'HashTable' How to remove the ModuleNotFoundError: No module named 'HashTable' error? Thanks   Hi, In your python environment you
Any Link Between ArrayList and HashMap - Java Interview Questions
interview questions which relates ArrayList and Hashmap. I mean how to link ArrayList and HashMap. Thanks Prakash  Hi Friend, Similarities: 1)ArrayList and HashMap both have a capacity. 2)Both are not synchronized. 3)Both
how to check particular value is avilable in hashmap - Java Beginners
how to check particular value is avilable in hashmap  Hi friends, i created a hashmap,in that hashmap key is tagginglist and value is tagsname... is available in the hashmap or not. my code is like this: Hashmap msgMap=new HashMap
when to use ArrayList and when to use HashMap - Java Interview Questions
ArrayList and when to use HashMap in web applications . Thanks Prakash  When.... But if you need to retrieve the objects more often then HashMap is preferable.This is the basic diff. Aray-List is fast for storing and hashmap is fast for retrieving
Example for when to use ArrayList and when to use HashMap - Java Interview Questions
u have replied this answer for when to use arraylist and hashmap " When your... to retrieve the objects more often then HashMap is preferable.This is the basic diff. Aray-List is fast for storing and hashmap is fast for retrieving. If your
HashMap - Struts
HashMap  Can you please get me an example code for using HashMap in Jsp and what for what purpose it is used
Collections in Java
Collections in Java are data-structures primarily defined through a set of classes and interface and used by Java professionals. Some collections in Java that are defined in Java collection framework are: Vectors, ArrayList, HashMap
HashMap and HashCode
.style1 { color: #FFFFFF; } HashMap and HashCode The HashMap... MapHashCode { public static void main(String args[]) { Map mp1 = new HashMap... = " + mp2.hashCode()); Map mp3 = new HashMap(); mp3.put(1, "E"
Example of values() method of HashMap.
Example of values() method of HashMap. The values() is the method of java HashMap. It returns a collection object of HashMap values.  Code: ...) { /* Create object of HashMap */ HashMap<Integer, String> obHashMap = new
J2ME HashTable Example
J2ME HashTable Example       To use the HashTable, java.util.Hashtable package must be imported into the application. Generally HashTable are used to map the keys to values
Example of containsKey method of HashMap.
Example of containsKey method of HashMap. The containsKey is a method of HashMap class. It always returns boolean value. It checks that the key is present or not in HashMap.  If the given key is present in map, than is returns true
Example of containsValues method of HashMap.
Example of containsValues method of HashMap. The containsValues is a method of HashMap class. It always returns boolean value. It checks, whether the values is present in HashMap or not.  If the given values is present in map, than
Example of keySet method of HashMap.
Example of keySet method of HashMap. In this example, we will introduce to you about the keySet method of HashMap. It returns a Set of keys of HashMap...(String[] arr) { /* Create object of HashMap */ (adsbygoogle
Query regarding hashmap
Query regarding hashmap  I want to store some names and ids in hashmap in session, then retrieve it on next page and iterate through ids to run a query using ids one at a time
Example of remove(Object key) method of HashMap.
Example of remove(Object key) method of HashMap. In this tutorial, you will see the use of remove method of HashMap class in java. It removes a value of specific key from HashMap. Code:  HashMapRemove.java (adsbygoogle
about hashmap - JSP-Servlet
about hashmap  hi.. i want suggestion in hashmap handling. in my program i have to pass parameters from different jsp pages and ve to store it. i ve used vector but its not recommended . thanks in advance
How to convert hashmap to json in Java?
the instruction in video titled "How to convert hashmap to json in Java?" where you can see the actual running example code. How to convert hashmap to json... hashmap to json in Java?ADS_TO_REPLACE_3 Code for converting the Map into JSON
Collection : HashMap Example
Collection : HashMap Example This tutorial will help you in understanding of HashMap concept. HashMap : The java.util.HashMap class implements Map... corresponding value. HashMap can allow multiple null key and multiple null value

Ads