Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

what is Hashmap & Hashtable wirh example?

Answer Posted / venki

1. Hashtable is synchronized which means Hashtable is thread
safe and that can be shared with multiple threads (Suitable
for multi threaded applications), HashMap not synchronized
(Suitable for single threaded applications).
2. Iterator in the Hashtable is fail-fast iterator and throw
ConcurrentModificationException if any other thread modifies
the map by adding or removing elements from the Map, while
Emnumeration in HashMap not.
3. Hashtable is slower than HashMap because of synchronization.
4. HashTable does not allow null for both keys and values,
you will get NullPointerException if you add null. whereas
HashMap allows one null key and any number of null values.
5. Hashtable and HashMap allows duplicate values.
6. Hashtable store objects in insertion order but HashMap
doesn’t store objects in insertion order, to store objects
in insertion order use LinkedHashMap.

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are different types of states exist for a thread?

1008


Is math class static in java?

1107


Which way a developer should use for creating thread, i.e. Sub classing thread or implementing runnable.

922


What is the unit of plancks constant?

1044


How many types of java are there?

970


What is java autoboxing?

938


How is Object Oriented Programming different from Procedure Oriented Programming?

1043


What is appletviewer?

1028


What is the public field modifier?

1018


what is function overloading in java?

1288


Is integer passed by reference in java?

1006


I want to re-reach and use an object once it has been garbage collected. Define how it’s possible?

1010


Is void a data type in java?

981


What is int argc char * argv?

1148


Why is the singleton pattern considered to be an anti pattern?

881